diff options
author | Lei Zhang <thestig@chromium.org> | 2018-03-02 23:54:26 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-02 23:54:26 +0000 |
commit | 9a7c2396705a23d1ce6bdba0025eb2316ae301c4 (patch) | |
tree | 13f7b1f84ec8c7dd87905c93edc9a3c56946997f | |
parent | 71cdd20e9d7400b8b2f34a07037564ec87bda3e8 (diff) | |
download | pdfium-chromium/3361.tar.xz |
Make EmbedderTest::WriteBitmapToPng() work with grayscale images.chromium/3362chromium/3361chromium/3360
Change-Id: I88d350171e2b18dc7776d17e845b55c361845721
Reviewed-on: https://pdfium-review.googlesource.com/27811
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | testing/embedder_test.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index b4f3851e3e..c39539b3fb 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -480,8 +480,15 @@ void EmbedderTest::WriteBitmapToPng(FPDF_BITMAP bitmap, static_cast<const unsigned char*>(FPDFBitmap_GetBuffer(bitmap)); std::vector<unsigned char> png_encoding; - bool encoded = image_diff_png::EncodeBGRAPNG(buffer, width, height, stride, - false, &png_encoding); + bool encoded; + if (FPDFBitmap_GetFormat(bitmap) == FPDFBitmap_Gray) { + encoded = image_diff_png::EncodeGrayPNG(buffer, width, height, stride, + &png_encoding); + } else { + encoded = image_diff_png::EncodeBGRAPNG(buffer, width, height, stride, + /*discard_transparency=*/false, + &png_encoding); + } ASSERT_TRUE(encoded); ASSERT_LT(filename.size(), 256u); |