14 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
15 ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
16 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
19 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
21 FPDFPage_InsertObject(page.get(),
nullptr);
22 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
24 FPDFPage_InsertObject(
nullptr, FPDFPageObj_NewImageObj(doc.get()));
25 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
29 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
30 ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
31 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
33 FPDFPage_InsertObject(page.get(), FPDFPageObj_NewImageObj(doc.get()));
34 EXPECT_EQ(1, FPDFPage_CountObjects(page.get()));
35 EXPECT_TRUE(FPDFPage_GenerateContent(page.get()));
39 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
40 ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
41 EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
43 constexpr int kBitmapSize = 50;
44 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0));
45 FPDFBitmap_FillRect(bitmap.get(), 0, 0, kBitmapSize, kBitmapSize, 0x00000000);
46 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap.get()));
47 EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap.get()));
49 ScopedFPDFPageObject page_image(FPDFPageObj_NewImageObj(doc.get()));
50 FPDF_PAGE pages_array[] = {page.get()};
52 FPDFImageObj_SetBitmap(pages_array, 0, page_image.get(), bitmap.get()));
53 static constexpr FS_MATRIX kScaleBitmapMatrix{kBitmapSize, 0, 0,
55 ASSERT_TRUE(FPDFPageObj_SetMatrix(page_image.get(), &kScaleBitmapMatrix));
56 FPDFPage_InsertObject(page.get(), page_image.release());
57 EXPECT_EQ(1, FPDFPage_CountObjects(page.get()));
58 EXPECT_TRUE(FPDFPage_GenerateContent(page.get()));
62 CreateEmptyDocumentWithoutFormFillEnvironment();
63 constexpr int kPageWidth = 200;
64 constexpr int kPageHeight = 200;
65 ScopedFPDFPage page(FPDFPage_New(document(), 0, kPageWidth, kPageHeight));
68 ScopedFPDFPageObject image(FPDFPageObj_NewImageObj(document()));
71 FileAccessForTesting file_access(
"mona_lisa.jpg");
72 FPDF_PAGE temp_page = page.get();
74 FPDFImageObj_LoadJpegFile(&temp_page, 1, image.get(), &file_access));
76 constexpr int kImageWidth = 120;
77 constexpr int kImageHeight = 120;
78 const char kImageChecksum[] =
"58589c36b3b27a0058f5ca1fbed4d5e5";
79 const char kPageChecksum[] =
"52b3a852f39c5fa9143e59d805dcb343";
81 ScopedFPDFBitmap image_bitmap(FPDFImageObj_GetBitmap(image.get()));
82 CompareBitmap(image_bitmap.get(), kImageWidth, kImageHeight,
86 FPDFImageObj_SetMatrix(image.get(), kImageWidth, 0, 0, kImageHeight, 0, 0);
87 FPDFPage_InsertObject(page.get(), image.release());
88 FPDFPage_GenerateContent(page.get());
90 ScopedFPDFBitmap page_bitmap = RenderPage(page.get());
91 CompareBitmap(page_bitmap.get(), kPageWidth, kPageHeight, kPageChecksum);
94 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
95 VerifySavedDocument(kPageWidth, kPageHeight, kPageChecksum);
99 CreateEmptyDocumentWithoutFormFillEnvironment();
100 constexpr int kPageWidth = 200;
101 constexpr int kPageHeight = 200;
102 ScopedFPDFPage page(FPDFPage_New(document(), 0, kPageWidth, kPageHeight));
105 ScopedFPDFPageObject image(FPDFPageObj_NewImageObj(document()));
108 FileAccessForTesting file_access(
"mona_lisa.jpg");
109 FPDF_PAGE temp_page = page.get();
110 EXPECT_TRUE(FPDFImageObj_LoadJpegFileInline(&temp_page, 1, image.get(),
113 constexpr int kImageWidth = 120;
114 constexpr int kImageHeight = 120;
115 const char kImageChecksum[] =
"58589c36b3b27a0058f5ca1fbed4d5e5";
116 const char kPageChecksum[] =
"52b3a852f39c5fa9143e59d805dcb343";
118 ScopedFPDFBitmap image_bitmap(FPDFImageObj_GetBitmap(image.get()));
119 CompareBitmap(image_bitmap.get(), kImageWidth, kImageHeight,
123 FPDFImageObj_SetMatrix(image.get(), kImageWidth, 0, 0, kImageHeight, 0, 0);
124 FPDFPage_InsertObject(page.get(), image.release());
125 FPDFPage_GenerateContent(page.get());
127 ScopedFPDFBitmap page_bitmap = RenderPage(page.get());
128 CompareBitmap(page_bitmap.get(), kPageWidth, kPageHeight, kPageChecksum);
131 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
132 VerifySavedDocument(kPageWidth, kPageHeight, kPageChecksum);
136 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
137 ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
138 ScopedFPDFPageObject image(FPDFPageObj_NewImageObj(doc.get()));
139 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(100, 100, 0));
141 FPDF_PAGE page_ptr = page.get();
142 FPDF_PAGE* pages = &page_ptr;
143 EXPECT_TRUE(FPDFImageObj_SetBitmap(
nullptr, 1, image.get(), bitmap.get()));
144 EXPECT_TRUE(FPDFImageObj_SetBitmap(pages, 0, image.get(), bitmap.get()));
145 EXPECT_FALSE(FPDFImageObj_SetBitmap(pages, 1,
nullptr, bitmap.get()));
146 EXPECT_FALSE(FPDFImageObj_SetBitmap(pages, 1, image.get(),
nullptr));
150 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
151 ScopedFPDFPageObject image(FPDFPageObj_NewImageObj(doc.get()));
156 EXPECT_FALSE(FPDFPageObj_GetMatrix(image.get(),
nullptr));
158 EXPECT_TRUE(FPDFPageObj_GetMatrix(image.get(), &matrix));
159 EXPECT_FLOAT_EQ(1.0f, matrix.a);
160 EXPECT_FLOAT_EQ(0.0f, matrix.b);
161 EXPECT_FLOAT_EQ(0.0f, matrix.c);
162 EXPECT_FLOAT_EQ(1.0f, matrix.d);
163 EXPECT_FLOAT_EQ(0.0f, matrix.e);
164 EXPECT_FLOAT_EQ(0.0f, matrix.f);
166 static constexpr FS_MATRIX kMatrix{1, 2, 3, 4, 5, 6};
167 EXPECT_TRUE(FPDFPageObj_SetMatrix(image.get(), &kMatrix));
168 EXPECT_TRUE(FPDFPageObj_GetMatrix(image.get(), &matrix));
169 EXPECT_FLOAT_EQ(1.0f, matrix.a);
170 EXPECT_FLOAT_EQ(2.0f, matrix.b);
171 EXPECT_FLOAT_EQ(3.0f, matrix.c);
172 EXPECT_FLOAT_EQ(4.0f, matrix.d);
173 EXPECT_FLOAT_EQ(5.0f, matrix.e);
174 EXPECT_FLOAT_EQ(6.0f, matrix.f);