[gs-cvs] gs/src
Ray Johnston
ray at casper.ghostscript.com
Tue Jul 30 21:43:47 PDT 2002
Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv8741/src
Modified Files:
zcolor2.c
Log Message:
Fix: The addition of the function sampling logic for DeviceN tint
transforms (fix 474544) tripped over a bogus assumption in Adobe Procset
for DuoTones generated by (at least) Photoshop. The assumption was that if
the alternate color space of a DeviceN space was being used, that the
procedure would run when 'setcolor' was executed and that the stack would
be accessible during that procedure. This fixes several bug reports with
'/stackunderflow in pop' errors including SF #549307, 576577 and 582385
for Artifex customers. Thanks to Dan Coby for the analysis and fix.
Index: zcolor2.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/zcolor2.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- zcolor2.c 16 Jun 2002 03:43:50 -0000 1.8
+++ zcolor2.c 31 Jul 2002 04:43:45 -0000 1.9
@@ -146,29 +146,6 @@
return is_subset;
}
-/* Define a dummy cleanup function. */
-private int
-devicen_no_cleanup(i_ctx_t *i_ctx_p)
-{
- return 0;
-}
-
-/* Discard the transformed color value. */
-private int
-devicen_setcolor_discard(i_ctx_t *i_ctx_p)
-{
- gs_state *pgs = igs;
- const gs_color_space *pcs = gs_currentcolorspace(pgs); /* always DeviceN */
- const gs_device_n_params *params = &pcs->params.device_n;
- const gs_color_space *pacs = (const gs_color_space *)¶ms->alt_space;
- int num_in = pcs->params.device_n.num_components; /* also on e-stack */
- int num_out = gs_color_space_num_components(pacs);
-
- esp -= num_in + 2; /* mark, count, tint values */
- osp -= num_out;
- return o_pop_estack;
-}
-
/* <param1> ... <paramN> setcolor - */
private int
zsetcolor(i_ctx_t *i_ctx_p)
@@ -223,13 +200,25 @@
return code;
if (pinst != 0)
istate->pattern = *op;
+ pop(n);
+ return code;
+}
+
+/*
+ * This operator will check if the current colorspace is DeviceN and the
+ * alternate colorspace is being used. This strange function is part of a
+ * kludge to get around a spec violation in Adobe Photoshop 5+. See
+ * comments in front of setcolor in lib/gs_ll3.ps for more info.
+ */
+private int
+zcheckdevicenaltused(i_ctx_t *i_ctx_p) /* - .checkdevicenaltused <bool> */
+{
+ os_ptr op = osp;
+ const gs_color_space *pcs = gs_currentcolorspace(igs);
+ bool result = false;
+ int code;
+
if(pcs->type->index == gs_color_space_index_DeviceN) {
- /*
- * Duotone code generated by Adobe PhotoShop 5+ expects that setcolor
- * (1) calls tint transform function (ttf). PLRM doesn't require this
- * (2) permits ttf to change op stack as side effect. PLRM forbids this
- * (3) assumes op stack is not changed when ttf is executed
- */
gs_color_space_type const *pcst = pcs->type;
int num_comp = pcst->num_components(pcs);
gx_device const *dev = gs_currentdevice(igs);
@@ -239,21 +228,32 @@
code=device_color_idx(dev, idx_ink);
if(code >= 0 && !is_subset_idx(idx_ink, num_ink, idx_comp, num_comp)) {
- int i;
-
- check_estack(num_comp + 4);
- for (i = 0; i < num_comp; ++i)
- *++esp = osp[i - num_comp + 1];
- ++esp;
- make_int(esp, num_comp);
- push_mark_estack(es_for, devicen_no_cleanup);
- push_op_estack(devicen_setcolor_discard);
- *++esp = istate->colorspace.procs.special.device_n.tint_transform;
- return o_push_estack;
+ result = true;
}
}
+ push(1);
+ make_bool(op, result ? 1 : 0);
+ return 0;
+}
+
+/*
+ * This operator will discard the components for a DeviceN alternate
+ * color space. This strange function is part of a kludge to get around
+ * a spec violation in Adobe Photoshop 5+. See comments in front of
+ * setcolor in lib/gs_ll3.ps for more info.
+ */
+private int
+zdiscardaltcolor(i_ctx_t *i_ctx_p) /* <param1> ... <paramN> .discardaltcolor - */
+{
+ os_ptr op = osp;
+ const gs_color_space *pcs = gs_currentcolorspace(igs);
+ int n = 0;
+
+ if(pcs->type->index == gs_color_space_index_DeviceN)
+ n = gs_color_space_num_components((gs_color_space *)
+ &pcs->params.device_n.alt_space);
pop(n);
- return code;
+ return 0;
}
/* <array> .setcolorspace - */
@@ -275,9 +275,10 @@
op_def_begin_level2(),
{"0currentcolor", zcurrentcolor},
{"0.currentcolorspace", zcurrentcolorspace},
- {"1setcolor", zsetcolor},
+ {"1.setcolor", zsetcolor},
{"1.setcolorspace", zsetcolorspace},
- {"0%.devicen_setcolor_discard", devicen_setcolor_discard},
+ {"0.checkdevicenaltused", zcheckdevicenaltused},
+ {"0.discardaltcolor", zdiscardaltcolor},
op_def_end(0)
};
More information about the gs-cvs
mailing list