From 9423400441f32a4c28651ee255cb95cecf49a57a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 21 Dec 2016 16:19:28 +0100 Subject: Common code to ensure we only premultiply pixmaps with additive colors. --- include/mupdf/fitz/colorspace.h | 9 ++++++++- include/mupdf/fitz/pixmap.h | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include/mupdf') diff --git a/include/mupdf/fitz/colorspace.h b/include/mupdf/fitz/colorspace.h index 398503d1..8a1c5caf 100644 --- a/include/mupdf/fitz/colorspace.h +++ b/include/mupdf/fitz/colorspace.h @@ -28,6 +28,13 @@ int fz_colorspace_is_indexed(fz_context *ctx, fz_colorspace *cs); */ int fz_colorspace_is_lab(fz_context *ctx, fz_colorspace *cs); +/* + fz_colorspace_is_subtractive: Return true if a colorspace is subtractive. + + True for CMYK, Separation and DeviceN colorspaces. +*/ +int fz_colorspace_is_subtractive(fz_context *ctx, fz_colorspace *pix); + /* fz_device_gray: Get colorspace representing device specific gray. */ @@ -77,7 +84,7 @@ typedef void (fz_colorspace_convert_fn)(fz_context *ctx, fz_colorspace *cs, cons typedef void (fz_colorspace_destruct_fn)(fz_context *ctx, fz_colorspace *cs); -fz_colorspace *fz_new_colorspace(fz_context *ctx, char *name, int n, fz_colorspace_convert_fn *to_rgb, fz_colorspace_convert_fn *from_rgb, fz_colorspace_destruct_fn *destruct, void *data, size_t size); +fz_colorspace *fz_new_colorspace(fz_context *ctx, char *name, int n, int is_subtractive, fz_colorspace_convert_fn *to_rgb, fz_colorspace_convert_fn *from_rgb, fz_colorspace_destruct_fn *destruct, void *data, size_t size); fz_colorspace *fz_new_indexed_colorspace(fz_context *ctx, fz_colorspace *base, int high, unsigned char *lookup); fz_colorspace *fz_keep_colorspace(fz_context *ctx, fz_colorspace *colorspace); void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace); diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h index b2a47407..6dfd4bae 100644 --- a/include/mupdf/fitz/pixmap.h +++ b/include/mupdf/fitz/pixmap.h @@ -261,6 +261,13 @@ void fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma); */ void fz_unmultiply_pixmap(fz_context *ctx, fz_pixmap *pix); +/* + fz_ensure_pixmap_is_additive: Convert a pixmap in a subtractive colorspace to an additive colorspace. + + Pixmaps with premultiplied alpha must be in an additive colorspace. +*/ +fz_pixmap *fz_ensure_pixmap_is_additive(fz_context *ctx, fz_pixmap *pix); + /* fz_convert_pixmap: Convert an existing pixmap to a desired colorspace. Other properties of the pixmap, such as resolution -- cgit v1.2.3