From 548334e57cae1039824d3db97bab5348fbe674e2 Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Thu, 3 Aug 2017 16:33:40 -0400 Subject: APIs and tests for retrieving raw/decoded data from image objects Added FPDFImageObj_GetImageDataDecoded() for retrieving the uncompressed data of an image, and FPDFImageObj_GetImageDataRaw() for retrieving the raw data of an image. * Refactored out DecodeStreamMaybeCopyAndReturnLength(), which is used to decode both attachment data and image data. * Within DecodeStreamMaybeCopyAndReturnLength(), used a different decoder function which takes care of multiple filters if exist. As a result, CPDF_StreamParser::DecodeInlineStream() which was made static previously is now moved back into namespace. Bug=pdfium:677 Change-Id: I22a22c99acaca98ef8c15f88911f2646a2c854d5 Reviewed-on: https://pdfium-review.googlesource.com/9811 Commit-Queue: Jane Liu Reviewed-by: Lei Zhang --- public/fpdf_edit.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'public/fpdf_edit.h') diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index e5607d1716..dc710b5f52 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -298,6 +298,35 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, DLLEXPORT FPDF_BITMAP STDCALL FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object); +// Get the decoded image data of |image_object|. The decoded data is the +// uncompressed image data, i.e. the raw image data after having all filters +// applied. |buffer| is only modified if |buflen| is longer than the length of +// the decoded image data. +// +// image_object - handle to an image object. +// buffer - buffer for holding the decoded image data in raw bytes. +// buflen - length of the buffer. +// +// Returns the length of the decoded image data. +DLLEXPORT unsigned long STDCALL +FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, + void* buffer, + unsigned long buflen); + +// Get the raw image data of |image_object|. The raw data is the image data as +// stored in the PDF without applying any filters. |buffer| is only modified if +// |buflen| is longer than the length of the raw image data. +// +// image_object - handle to an image object. +// buffer - buffer for holding the raw image data in raw bytes. +// buflen - length of the buffer. +// +// Returns the length of the raw image data. +DLLEXPORT unsigned long STDCALL +FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object, + void* buffer, + unsigned long buflen); + // Create a new path object at an initial position. // // x - initial horizontal position. -- cgit v1.2.3