diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2017-07-26 23:06:07 -0700 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-10-24 15:16:34 +0100 |
commit | fee66b72d296ecdd9654109c31e9dbfa4811d034 (patch) | |
tree | 0ca19bbeed8aa6e385ef23fe3d3a5a8207630ca7 /source/fitz/draw-device.c | |
parent | 8080868ad41df95ba376bd451612fcb23a4a3daf (diff) | |
download | mupdf-fee66b72d296ecdd9654109c31e9dbfa4811d034.tar.xz |
Logic for Sep and DeviceN colorspaces with C,M,Y, or K.
Special care is required when the DeviceN color space has
cyan, magenta, yellow or black.
For example, even if we support separations in the destination, if
the color space has CMY or K as one of its colorants and we are
drawing to an RGB or Gray pixmap we will want to do the tint transform.
Also if the pixmap has no seps memember present, we support the
separations if the destination is CMYK and the DeviceN colorspace
has no "Spot" (non-CMYK) colorants.
Diffstat (limited to 'source/fitz/draw-device.c')
-rw-r--r-- | source/fitz/draw-device.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index fdc9cd20..7a47e707 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -328,6 +328,26 @@ static inline fz_matrix concat(const fz_matrix *one, const fz_matrix *two) return ctm; } +static int +colors_supported(fz_context *ctx, fz_colorspace *cs, fz_pixmap *dest) +{ + /* Even if we support separations in the destination, if the color space has CMY or K as one of + * its colorants and we are in RGB or Gray we will want to do the tint transform */ + if (!fz_colorspace_is_subtractive(ctx, dest->colorspace) && fz_colorspace_device_n_has_cmyk(ctx, cs)) + return 0; + + /* If we have separations then we should support it */ + if (dest->seps) + return 1; + + /* If our destination is CMYK and the source color space is only C, M, Y or K we support it + * even if we have no seps */ + if (fz_colorspace_is_subtractive(ctx, dest->colorspace) && fz_colorspace_device_n_info(ctx, cs) == FZ_DEVICE_N_CMYK_ONLY) + return 1; + + return 0; +} + static void resolve_color(fz_context *ctx, const float *color, fz_colorspace *colorspace, float alpha, const fz_color_params *color_params, unsigned char *colorbv, fz_pixmap *dest, fz_colorspace *prf) { @@ -344,7 +364,7 @@ resolve_color(fz_context *ctx, const float *color, fz_colorspace *colorspace, fl if (n == 0) i = 0; - else if (fz_colorspace_is_device_n(ctx, colorspace) && dest->seps) + else if (fz_colorspace_is_device_n(ctx, colorspace) && colors_supported(ctx, colorspace, dest)) { fz_convert_separation_colors(ctx, color_params, dest->colorspace, dest->seps, colorfv, colorspace, color); for (i = 0; i < n; i++) |