diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2022-04-01 14:24:00 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2022-04-01 14:50:24 +0100 |
commit | 4659f3aedb77a039e54e4e1f3038cafa0c10a283 (patch) | |
tree | f42a0f9e3122b056ac1a69792edf17929db96086 /xps | |
parent | 13320ddef4784bca1dfdb65aacbd6fa8a8cf5883 (diff) | |
download | ghostpdl-4659f3aedb77a039e54e4e1f3038cafa0c10a283.tar.gz |
pdfwrite - fix group attributes ColorSpace
Bug #705079 "Blending issue with the drop-shadow image"
This turns out to be because the new PDF interpreter was not setting the
current colour space to be the /CS from the XObject group attributes
dictionary.
Attempting to do this turned out to be well nigh impossible. We can't
(not sure why but it certainly doesn't work) use gsave/grestore to
preserve the colour space. Attempting to replicate the old PDF interpreter
in PostScript behaviour and copying the current colour and spaces led
to seg faults.
On closer inspection, however, it turns out that the only reason for
setting the current colour space is because the pdf14 compositor
discards the ColorSpace passed in from the interpreter. The interpreter
passes a gs_transparency_group_params_t structure, which cotnains an
entry for the ColorSpace, the graphics library however copies the entries
into a gs_pdf14trans_params_t which does *not* contain a ColorSpace.
I've no idea what the point of this was, but it seems mad. This commit
adds a new member 'ColorSpace' to the gs_pdf14trans_params_t
structure, and initialises it from the gs_transparency_group_params_t
structure. We then modify pdfwrite to use that instead of the current
colour space.
The PostScript and C based PDF interpreters both already initialised
that member so nothing further needed to be done there. The XPS
interpreter did not initialise that member, and so we also update it
to do so.
This fixes the bug and shows no diffs on the cluster.
Finally update the PDF interpreter, it seems that the old code
accepted a /ColorSpace in place of a /CS in the group attributes
dictionary even though this is technically invalid.
Fall back to the current colour space if no /CS or /ColorSpace is
present in the group attributes dictionary (this is illegal but
it might 'work').
Finally add a check, as per the old code, to see that the number
of components for the colour space matches the number of components
in the /BC array if one is supplied. Unlike Acrobat we choose not
to ignore the SMask if they don't match.
We do emit warnings/errors for all the above conditions.
Diffstat (limited to 'xps')
-rw-r--r-- | xps/xpsgradient.c | 3 | ||||
-rw-r--r-- | xps/xpsimage.c | 3 | ||||
-rw-r--r-- | xps/xpsopacity.c | 3 |
3 files changed, 6 insertions, 3 deletions
diff --git a/xps/xpsgradient.c b/xps/xpsgradient.c index d941f46c7..70a8a3767 100644 --- a/xps/xpsgradient.c +++ b/xps/xpsgradient.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -984,6 +984,7 @@ xps_parse_gradient_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dic gs_setblendmode(ctx->pgs, BLEND_MODE_Normal); gs_trans_mask_params_init(¶ms, TRANSPARENCY_MASK_Luminosity); + params.ColorSpace = gs_currentcolorspace_inline(ctx->pgs); gs_begin_transparency_mask(ctx->pgs, ¶ms, &bbox, 0); /* I dont like this, but dont want to change interface of draw */ /* For the opacity case, we want to make sure the functions diff --git a/xps/xpsimage.c b/xps/xpsimage.c index 7207ce749..83609ea23 100644 --- a/xps/xpsimage.c +++ b/xps/xpsimage.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -319,6 +319,7 @@ xps_paint_image_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict, gs_setfillconstantalpha(ctx->pgs, 1.0); gs_setstrokeconstantalpha(ctx->pgs, 1.0); gs_trans_mask_params_init(¶ms, TRANSPARENCY_MASK_Luminosity); + params.ColorSpace = gs_currentcolorspace_inline(ctx->pgs); gs_begin_transparency_mask(ctx->pgs, ¶ms, &bbox, 0); code = xps_paint_image_brush_imp(ctx, image, 1); if (code < 0) diff --git a/xps/xpsopacity.c b/xps/xpsopacity.c index f8dca49d8..a6e40a96d 100644 --- a/xps/xpsopacity.c +++ b/xps/xpsopacity.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -90,6 +90,7 @@ xps_begin_opacity(xps_context_t *ctx, char *base_uri, xps_resource_t *dict, gs_trans_mask_params_init(&tmp, TRANSPARENCY_MASK_Luminosity); gs_gsave(ctx->pgs); gs_setcolorspace(ctx->pgs, ctx->gray_lin); + tmp.ColorSpace = ctx->gray_lin; gs_begin_transparency_mask(ctx->pgs, &tmp, &bbox, 0); /* Create a path if we dont have one that defines the opacity. |