From 28fb7ba083dba5e09493fd37a11994de51527dfc Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Wed, 2 Aug 2017 21:45:57 -0400 Subject: APIs and tests for extracting bitmaps from image objects Added FPDFImageObj_GetBitmap() that returns the bitmap of an image object, and a FPDFBitmap_GetFormat() that returns the format of a bitmap. * Fixed a small bitmap conversion bug in cfx_dibsource.cpp. * Enabled EmbedderTest::CompareBitmap() to support different formats of bitmaps. * Added an embedder test and a test PDF file with images of many different formats. Bug=pdfium:677 Change-Id: I6a72f9d969cf5f3577db9400ca33197c213622ed Reviewed-on: https://pdfium-review.googlesource.com/9690 Reviewed-by: Lei Zhang Commit-Queue: Jane Liu --- core/fxge/dib/cfx_dibsource.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index a0ed95055b..3a2179660f 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -271,12 +271,14 @@ void ConvertBuffer_IndexCopy(uint8_t* dest_buf, if (pSrcBitmap->GetBPP() == 1) { for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; - memset(dest_scan, 0, width); + // Set all destination pixels to be white initially. + memset(dest_scan, 255, width); const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); for (int col = src_left; col < src_left + width; col++) { - if (src_scan[col / 8] & (1 << (7 - col % 8))) { - *dest_scan = 1; - } + // If the source bit is set, then set the destination pixel to be black. + if (src_scan[col / 8] & (1 << (7 - col % 8))) + *dest_scan = 0; + dest_scan++; } } -- cgit v1.2.3