summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview_embeddertest.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-07-26 13:50:12 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-26 19:56:53 +0000
commit60bde10736fd78a2333cf1513aea779df9346b35 (patch)
treeed792453114a14937c0be4169a972e633ddf1a08 /fpdfsdk/fpdfview_embeddertest.cpp
parente9af3798cbee81bc0093d4be024ecb6c2ea19bd9 (diff)
downloadpdfium-60bde10736fd78a2333cf1513aea779df9346b35.tar.xz
Fix FPDF_RenderPageBitmapWithMatrix
This CL fixes FPDF_RenderPageBitmapWithMatrix and improves tests. Bug: pdfium:837 Change-Id: I98f90b667cc9a50fb0e915b8a758603488b44d40 Reviewed-on: https://pdfium-review.googlesource.com/9010 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfview_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfview_embeddertest.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index f36edbc4d6..a986a1cd96 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -330,19 +330,21 @@ TEST_F(FPDFViewEmbeddertest, Hang_360) {
}
TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) {
- const char kAllBlackMd5sum[] = "5708fc5c4a8bd0abde99c8e8f0390615";
- const char kTopLeftQuarterBlackMd5sum[] = "24e4d1ec06fa0258af758cfc8b2ad50a";
+ const char kOriginalMD5[] = "210157942bcce97b057a1107a1fd62f8";
+ const char kTopLeftQuarterMD5[] = "c54d58dda13e3cd04eb63e1d0db0feda";
+ const char kTrimmedMD5[] = "88225d7951a21d0eef191cfed06c36ce";
+ const char kRotatedMD5[] = "7d38bc58aa50ad271bc432e77256d3de";
- EXPECT_TRUE(OpenDocument("black.pdf"));
+ EXPECT_TRUE(OpenDocument("rectangles.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);
+ EXPECT_EQ(200, width);
+ EXPECT_EQ(200, height);
FPDF_BITMAP bitmap = RenderPage(page);
- CompareBitmap(bitmap, width, height, kAllBlackMd5sum);
+ CompareBitmap(bitmap, width, height, kOriginalMD5);
FPDFBitmap_Destroy(bitmap);
// Try rendering with an identity matrix. The output should be the same as
@@ -364,17 +366,39 @@ TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) {
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);
+ CompareBitmap(bitmap, width, height, kOriginalMD5);
FPDFBitmap_Destroy(bitmap);
- // Now render again with the image scaled.
+ // Now render again with the image scaled smaller.
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);
+ CompareBitmap(bitmap, width, height, kTopLeftQuarterMD5);
+ FPDFBitmap_Destroy(bitmap);
+
+ // Now render again with the image scaled larger horizontally (will be
+ // trimmed).
+ matrix.a = 2;
+ matrix.d = 1;
+ 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, kTrimmedMD5);
+ FPDFBitmap_Destroy(bitmap);
+
+ // Now try a 90 degree rotation
+ matrix.a = 0;
+ matrix.b = 1;
+ matrix.c = -1;
+ matrix.d = 0;
+ matrix.e = width;
+ 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, kRotatedMD5);
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);