summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2013-08-16 23:28:28 +0200
committerRobin Watts <robin.watts@artifex.com>2013-08-28 13:35:55 +0100
commit5127d6fe0fb46f4baf0b67dc8c966cc8cc676475 (patch)
tree9536097471536a486eaa9e8653562e16513fadaf
parenta6772e77b84a59b59ffdf501f9c5991fbcec4a3d (diff)
downloadmupdf-5127d6fe0fb46f4baf0b67dc8c966cc8cc676475.tar.xz
invert color transformed CMYK JPEG images
This fixes among others 693274 - cmyk jpeg image.xps from bug 693274.
-rw-r--r--include/mupdf/fitz/image.h1
-rw-r--r--source/fitz/image.c10
-rw-r--r--source/xps/xps-image.c1
3 files changed, 12 insertions, 0 deletions
diff --git a/include/mupdf/fitz/image.h b/include/mupdf/fitz/image.h
index 5f258844..7ba62f8a 100644
--- a/include/mupdf/fitz/image.h
+++ b/include/mupdf/fitz/image.h
@@ -77,6 +77,7 @@ struct fz_image_s
fz_pixmap *tile; /* Private to the implementation */
int xres; /* As given in the image, not necessarily as rendered */
int yres; /* As given in the image, not necessarily as rendered */
+ int invert_cmyk_jpeg;
};
fz_pixmap *fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *cs, int indexed);
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 0aeb449d..899232e0 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -299,6 +299,16 @@ fz_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h)
indexed = fz_colorspace_is_indexed(image->colorspace);
tile = fz_decomp_image_from_stream(ctx, stm, image, 0, indexed, l2factor, native_l2factor);
+
+ /* CMYK JPEGs in XPS documents have to be inverted */
+ if (image->invert_cmyk_jpeg &&
+ image->buffer->params.type == FZ_IMAGE_JPEG &&
+ image->colorspace == fz_device_cmyk(ctx) &&
+ image->buffer->params.u.jpeg.color_transform)
+ {
+ fz_invert_pixmap(ctx, tile);
+ }
+
break;
}
diff --git a/source/xps/xps-image.c b/source/xps/xps-image.c
index cff7860d..9b2aefcb 100644
--- a/source/xps/xps-image.c
+++ b/source/xps/xps-image.c
@@ -110,6 +110,7 @@ xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *ar
fz_try(doc->ctx)
{
image = xps_load_image(doc->ctx, part);
+ image->invert_cmyk_jpeg = 1;
}
fz_always(doc->ctx)
{