summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-08-02 21:45:57 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-03 20:20:02 +0000
commit28fb7ba083dba5e09493fd37a11994de51527dfc (patch)
treede009c28d419bed2a9a123c257f923893db0b053 /public
parent844d5dac8a6c97b2cd3bd92bf07d0cc62158408a (diff)
downloadpdfium-28fb7ba083dba5e09493fd37a11994de51527dfc.tar.xz
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 <thestig@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
Diffstat (limited to 'public')
-rw-r--r--public/fpdf_edit.h10
-rw-r--r--public/fpdfview.h35
2 files changed, 38 insertions, 7 deletions
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index cfed93172f..e5607d1716 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -288,6 +288,16 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
FPDF_PAGEOBJECT image_object,
FPDF_BITMAP bitmap);
+// Get a bitmap rasterisation of |image_object|. The returned bitmap will be
+// owned by the caller, and FPDFBitmap_Destroy() must be called on the returned
+// bitmap when it is no longer needed.
+//
+// image_object - handle to an image object.
+//
+// Returns the bitmap.
+DLLEXPORT FPDF_BITMAP STDCALL
+FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object);
+
// Create a new path object at an initial position.
//
// x - initial horizontal position.
diff --git a/public/fpdfview.h b/public/fpdfview.h
index 55897eb467..4e2e698918 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -626,7 +626,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
// Parameters:
// bitmap - Handle to the device independent bitmap (as the
// output buffer). The bitmap handle can be created
-// by FPDFBitmap_Create.
+// by FPDFBitmap_Create or retrieved from an image
+// object by FPDFImageObj_GetBitmap.
// page - Handle to the page. Returned by FPDF_LoadPage
// start_x - Left pixel position of the display area in
// bitmap coordinates.
@@ -660,7 +661,8 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
// Parameters:
// bitmap - Handle to the device independent bitmap (as the
// output buffer). The bitmap handle can be created
-// by FPDFBitmap_Create.
+// by FPDFBitmap_Create or retrieved by
+// FPDFImageObj_GetBitmap.
// page - Handle to the page. Returned by FPDF_LoadPage
// matrix - The transform matrix.
// clipping - The rect to clip to.
@@ -820,6 +822,8 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
int alpha);
// More DIB formats
+// Unknown or unsupported format.
+#define FPDFBitmap_Unknown 0
// Gray scale bitmap, one byte per pixel.
#define FPDFBitmap_Gray 1
// 3 bytes per pixel, byte order: blue, green, red.
@@ -860,6 +864,18 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
void* first_scan,
int stride);
+// Function: FPDFBitmap_GetFormat
+// Get the format of the bitmap.
+// Parameters:
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
+// Return value:
+// The format of the bitmap.
+// Comments:
+// Only formats supported by FPDFBitmap_CreateEx are supported by this
+// function; see the list of such formats above.
+DLLEXPORT int STDCALL FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
+
// Function: FPDFBitmap_FillRect
// Fill a rectangle in a bitmap.
// Parameters:
@@ -894,7 +910,8 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
// Function: FPDFBitmap_GetBuffer
// Get data buffer of a bitmap.
// Parameters:
-// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
// Return value:
// The pointer to the first byte of the bitmap buffer.
// Comments:
@@ -911,7 +928,8 @@ DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
// Function: FPDFBitmap_GetWidth
// Get width of a bitmap.
// Parameters:
-// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
// Return value:
// The width of the bitmap in pixels.
DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
@@ -919,7 +937,8 @@ DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
// Function: FPDFBitmap_GetHeight
// Get height of a bitmap.
// Parameters:
-// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
// Return value:
// The height of the bitmap in pixels.
DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
@@ -927,7 +946,8 @@ DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
// Function: FPDFBitmap_GetStride
// Get number of bytes for each line in the bitmap buffer.
// Parameters:
-// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
// Return value:
// The number of bytes for each line in the bitmap buffer.
// Comments:
@@ -937,7 +957,8 @@ DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
// Function: FPDFBitmap_Destroy
// Destroy a bitmap and release all related buffers.
// Parameters:
-// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
+// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
+// or FPDFImageObj_GetBitmap.
// Return value:
// None.
// Comments: