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 --- fpdfsdk/fpdfview.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'fpdfsdk/fpdfview.cpp') diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 355fcb3f8f..5aa80139ae 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -1126,6 +1126,26 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, return pBitmap.Leak(); } +DLLEXPORT int STDCALL FPDFBitmap_GetFormat(FPDF_BITMAP bitmap) { + if (!bitmap) + return FPDFBitmap_Unknown; + + FXDIB_Format format = CFXBitmapFromFPDFBitmap(bitmap)->GetFormat(); + switch (format) { + case FXDIB_8bppRgb: + case FXDIB_8bppMask: + return FPDFBitmap_Gray; + case FXDIB_Rgb: + return FPDFBitmap_BGR; + case FXDIB_Rgb32: + return FPDFBitmap_BGRx; + case FXDIB_Argb: + return FPDFBitmap_BGRA; + default: + return FPDFBitmap_Unknown; + } +} + DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, -- cgit v1.2.3