summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/embedder_test.cpp11
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);