197 uint8_t pattern[40] = {
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
200 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 uint8_t pattern20[40] = {
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 uint8_t pattern22[40] = {
216 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
217 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 uint8_t pattern161[40] = {
225 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
226 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
227 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 auto expected161 =
std::make_unique<
CJBig2_Image>(25, 5, 8, pattern161);
246 auto sub = img32->SubImage(0, 0, 0, 0);
247 EXPECT_EQ(sub->width(), 0);
248 EXPECT_EQ(sub->height(), 0);
251 sub = img32->SubImage(0, 0, 32, 5);
252 EXPECT_EQ(sub->width(), 32);
253 EXPECT_EQ(sub->height(), 5);
254 CheckImageEq(img32.get(), sub.get(), __LINE__);
256 sub = img37->SubImage(0, 0, 32, 5);
257 EXPECT_EQ(sub->width(), 32);
258 EXPECT_EQ(sub->height(), 5);
259 CheckImageEq(img32.get(), sub.get(), __LINE__);
262 sub = img32->SubImage(2, 0, 30, 5);
263 CheckImageEq(expected20.get(), sub.get(), __LINE__);
265 sub = img37->SubImage(2, 2, 30, 5);
266 CheckImageEq(expected22.get(), sub.get(), __LINE__);
269 sub = img37->SubImage(16, 1, 25, 5);
270 CheckImageEq(expected161.get(), sub.get(), __LINE__);
273 sub = img37->SubImage(32, 0, 32, 5);
274 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
277 sub = img37->SubImage(2000, 0, 32, 5);
278 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
281 sub = img37->SubImage(0, 2000, 32, 5);
282 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
285 sub = img37->SubImage(-1, 0, 32, 5);
286 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
289 sub = img37->SubImage(0, -1, 32, 5);
290 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
293 sub = img37->SubImage(-1, 0, 32, 5);
294 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
297 sub = img37->SubImage(0, -1, 32, 5);
298 CheckImageEq(expected_zeros.get(), sub.get(), __LINE__);
301 sub = img37->SubImage(0, 0, 128, 5);
302 EXPECT_EQ(128, sub->width());
303 EXPECT_EQ(5, sub->height());
306 sub = img37->SubImage(0, 0, 32, 40);
307 EXPECT_EQ(32, sub->width());
308 EXPECT_EQ(40, sub->height());
314 uint8_t pattern[24] = {
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
320 uint8_t expected_pattern[24] = {
321 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 auto expected =
std::make_unique<
CJBig2_Image>(37, 3, 8, expected_pattern);
339 img->CopyLine(-1, 0);
341 img->CopyLine(-1, -1);
344 CheckImageEq(expected.get(), img.get(), __LINE__);