Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Unified Diff: fpdfsdk/fpdfview_embeddertest.cpp

Issue 2526473002: Add FPDF_RenderPageBitmapWithMatrix. (Closed)
Patch Set: rebase, nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/fpdfview_c_api_test.c ('k') | public/fpdfview.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfview_embeddertest.cpp
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 65e52fec39e8fb5f027d673dde8e1ed8e6033aab..1d94b7255332c11d3371b564a4438490da0a472e 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -327,3 +327,54 @@ TEST_F(FPDFViewEmbeddertest, Hang_355) {
TEST_F(FPDFViewEmbeddertest, Hang_360) {
EXPECT_FALSE(OpenDocument("bug_360.pdf"));
}
+
+TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) {
+ const char kAllBlackMd5sum[] = "5708fc5c4a8bd0abde99c8e8f0390615";
+ const char kTopLeftQuarterBlackMd5sum[] = "24e4d1ec06fa0258af758cfc8b2ad50a";
+
+ EXPECT_TRUE(OpenDocument("black.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+ const int width = static_cast<int>(FPDF_GetPageWidth(page));
+ const int height = static_cast<int>(FPDF_GetPageHeight(page));
+ EXPECT_EQ(612, width);
+ EXPECT_EQ(792, height);
+
+ FPDF_BITMAP bitmap = RenderPage(page);
+ CompareBitmap(bitmap, width, height, kAllBlackMd5sum);
+ FPDFBitmap_Destroy(bitmap);
+
+ // Try rendering with an identity matrix. The output should be the same as
+ // the RenderPage() output.
+ FS_MATRIX matrix;
+ matrix.a = 1;
+ matrix.b = 0;
+ matrix.c = 0;
+ matrix.d = 1;
+ matrix.e = 0;
+ matrix.f = 0;
+
+ FS_RECTF rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = width;
+ rect.bottom = height;
+
+ bitmap = FPDFBitmap_Create(width, height, 0);
+ FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF);
+ FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0);
+ CompareBitmap(bitmap, width, height, kAllBlackMd5sum);
+ FPDFBitmap_Destroy(bitmap);
+
+ // Now render again with the image scaled.
+ matrix.a = 0.5;
+ matrix.d = 0.5;
+
+ bitmap = FPDFBitmap_Create(width, height, 0);
+ FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF);
+ FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0);
+ CompareBitmap(bitmap, width, height, kTopLeftQuarterBlackMd5sum);
+ FPDFBitmap_Destroy(bitmap);
+
+ UnloadPage(page);
+}
« no previous file with comments | « fpdfsdk/fpdfview_c_api_test.c ('k') | public/fpdfview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698