summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-08-16 11:25:35 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-16 17:14:22 +0000
commitca89829775fec2968b51fe5abad86bad1b6a277b (patch)
treef276524600e7a4b8fa1cfb526302f330626cd815 /public
parenteb14e04c79c575146fe96c025dbf56b7440870c7 (diff)
downloadpdfium-ca89829775fec2968b51fe5abad86bad1b6a277b.tar.xz
API and test for retrieving metadata from image objects
Added FPDFImageObj_GetImageMetadata() for retriving the image metadata of image objects, including its dimension, DPI, bits per pixel, and colorspace. * Added a corresponding embedder test. Bug=pdfium:677 Change-Id: I4229334d1ac2125b21a46e2e44ea937ea2e94b51 Reviewed-on: https://pdfium-review.googlesource.com/10110 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
Diffstat (limited to 'public')
-rw-r--r--public/fpdf_edit.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index f75744599f..c547f07890 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -20,6 +20,20 @@
#define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16))
#define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24))
+// Refer to PDF Reference version 1.7 table 4.12 for all color space families.
+#define FPDF_COLORSPACE_UNKNOWN 0
+#define FPDF_COLORSPACE_DEVICEGRAY 1
+#define FPDF_COLORSPACE_DEVICERGB 2
+#define FPDF_COLORSPACE_DEVICECMYK 3
+#define FPDF_COLORSPACE_CALGRAY 4
+#define FPDF_COLORSPACE_CALRGB 5
+#define FPDF_COLORSPACE_LAB 6
+#define FPDF_COLORSPACE_ICCBASED 7
+#define FPDF_COLORSPACE_SEPARATION 8
+#define FPDF_COLORSPACE_DEVICEN 9
+#define FPDF_COLORSPACE_INDEXED 10
+#define FPDF_COLORSPACE_PATTERN 11
+
// The page object constants.
#define FPDF_PAGEOBJ_UNKNOWN 0
#define FPDF_PAGEOBJ_TEXT 1
@@ -47,6 +61,21 @@
#define FPDF_PRINTMODE_POSTSCRIPT2 2
#define FPDF_PRINTMODE_POSTSCRIPT3 3
+typedef struct FPDF_IMAGEOBJ_METADATA {
+ // The image width in pixels.
+ unsigned int width;
+ // The image height in pixels.
+ unsigned int height;
+ // The image's horizontal pixel-per-inch.
+ float horizontal_dpi;
+ // The image's vertical pixel-per-inch.
+ float vertical_dpi;
+ // The number of bits used to represent each pixel.
+ unsigned int bits_per_pixel;
+ // The image's colorspace. See above for the list of FPDF_COLORSPACE_*.
+ int colorspace;
+} FPDF_IMAGEOBJ_METADATA;
+
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -366,6 +395,22 @@ FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object,
void* buffer,
unsigned long buflen);
+// Get the image metadata of |image_object|, including dimension, DPI, bits per
+// pixel, and colorspace. If the |image_object| is not an image object or if it
+// does not have an image, then the return value will be false. Otherwise,
+// failure to retrieve any specific parameter would result in its value being 0.
+//
+// image_object - handle to an image object.
+// page - handle to the page that |image_object| is on. Required for
+// retrieving the image's bits per pixel and colorspace.
+// metadata - receives the image metadata; must not be NULL.
+//
+// Returns true if successful.
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
+ FPDF_PAGE page,
+ FPDF_IMAGEOBJ_METADATA* metadata);
+
// Create a new path object at an initial position.
//
// x - initial horizontal position.