summaryrefslogtreecommitdiff
path: root/source/fitz/colorspace.c
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2017-07-31 08:48:23 -0700
committerRobin Watts <robin.watts@artifex.com>2017-10-24 15:16:35 +0100
commitb9ed019811830bea9add8c36a10ae4a1badd93d3 (patch)
tree4eb7af1fc2f281b794d51cee517c85d5c72ec797 /source/fitz/colorspace.c
parent72c202c98ec708d48d54c21935430a2c733675e7 (diff)
downloadmupdf-b9ed019811830bea9add8c36a10ae4a1badd93d3.tar.xz
Implement DeviceGray to K
When source color is DeviceGray, and the destination color CMYK we should map the gray values to K. See note in Section 6.3 of PDF spec.
Diffstat (limited to 'source/fitz/colorspace.c')
-rw-r--r--source/fitz/colorspace.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index ed6f768e..ceec805e 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -2616,6 +2616,13 @@ icc_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *
unsigned char *inputpos, *outputpos;
int src_n;
+ /* Handle DeviceGray->CMYK as K only. See note in Section 6.3 of PDF spec.*/
+ if (fz_colorspace_is_device_gray(ctx, src->colorspace) && fz_colorspace_is_subtractive(ctx, dst->colorspace))
+ {
+ fast_gray_to_cmyk(ctx, dst, src, prf, default_cs, color_params, copy_spots);
+ return;
+ }
+
/* Check if we have to do a color space default substitution */
if (default_cs)
{
@@ -3079,7 +3086,15 @@ icc_conv_color(fz_context *ctx, fz_color_converter *cc, float *dstv, const float
unsigned short dstv_s[FZ_MAX_COLORS];
unsigned short srcv_s[FZ_MAX_COLORS];
- if (link->is_identity)
+ /* Special case. Link is NULL if we are doing DeviceGray to CMYK */
+ if (link == NULL)
+ {
+ dstv[0] = 0;
+ dstv[1] = 0;
+ dstv[2] = 0;
+ dstv[3] = 1 - srcv[0];
+ }
+ else if (link->is_identity)
{
for (i = 0; i < src_n; i++)
dstv[i] = srcv[i];
@@ -3311,7 +3326,10 @@ void fz_find_color_converter(fz_context *ctx, fz_color_converter *cc, const fz_c
cc->convert = icc_conv_color;
else
cc->convert = icc_base_conv_color;
- cc->link = fz_get_icc_link(ctx, ds, 0, ss_base, 0, is, params, 2, 0, &cc->n);
+
+ /* Special case. Do not set link if we are doing DeviceGray to CMYK */
+ if (!(fz_colorspace_is_device_gray(ctx, ss_base) && fz_colorspace_is_subtractive(ctx, ds)))
+ cc->link = fz_get_icc_link(ctx, ds, 0, ss_base, 0, is, params, 2, 0, &cc->n);
}
else
cc->convert = std_conv_color;