[gs-cvs] rev 8679 - trunk/gs/src
mvrhel at ghostscript.com
mvrhel at ghostscript.com
Tue Apr 29 21:51:02 PDT 2008
Author: mvrhel
Date: 2008-04-29 21:51:02 -0700 (Tue, 29 Apr 2008)
New Revision: 8679
Modified:
trunk/gs/src/gscdevn.c
trunk/gs/src/gscspace.c
trunk/gs/src/gsnamecl.c
trunk/gs/src/gsncdummy.c
trunk/gs/src/gxcmap.c
trunk/gs/src/lib.mak
Log:
Fixed issue with NULL pointer in gsncdummy.c when ICC color space was used in custom color callback. Also, made the object based coloring an option define and fixed minor header issues.
Modified: trunk/gs/src/gscdevn.c
===================================================================
--- trunk/gs/src/gscdevn.c 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/gscdevn.c 2008-04-30 04:51:02 UTC (rev 8679)
@@ -34,6 +34,7 @@
#include "gxdevcli.h"
#include "gsovrc.h"
#include "stream.h"
+#include "gsnamecl.h" /* Custom color call back define */
/* ---------------- Color space ---------------- */
Modified: trunk/gs/src/gscspace.c
===================================================================
--- trunk/gs/src/gscspace.c 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/gscspace.c 2008-04-30 04:51:02 UTC (rev 8679)
@@ -28,6 +28,7 @@
#include "gxdevcli.h"
#include "gzstate.h"
#include "stream.h"
+#include "gsnamecl.h" /* Custom color call back define */
static cs_proc_install_cspace(gx_install_DeviceGray);
static cs_proc_install_cspace(gx_install_DeviceRGB);
Modified: trunk/gs/src/gsnamecl.c
===================================================================
--- trunk/gs/src/gsnamecl.c 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/gsnamecl.c 2008-04-30 04:51:02 UTC (rev 8679)
@@ -40,6 +40,7 @@
#include "gxdevice.h"
#include "gzstate.h"
#include "gsutil.h"
+#include "gsnamecl.h" /* Custom color call back define */
#if ENABLE_CUSTOM_COLOR_CALLBACK /* Defined in src/gsnamecl.h */
Modified: trunk/gs/src/gsncdummy.c
===================================================================
--- trunk/gs/src/gsncdummy.c 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/gsncdummy.c 2008-04-30 04:51:02 UTC (rev 8679)
@@ -20,8 +20,11 @@
* all lines and fills to shades of blue. if the flag is 0 then our example
* only handles PANTONE colors (see comment below).
*/
-#define OBJECT_TYPE_EXAMPLE 1 /* 0 --> disabled, 1 --> enabled */
+/* Added these two defines so that I could compare to ghost script rendering color */
+
+#define OBJECT_TYPE_EXAMPLE 0 /* 0 --> disabled, 1 --> enabled */
+#define PANTONE_ONLY 0
/*
* This module has been created to demonstrate how to support the use of
* PANTONE colors to the Ghostscript graphics library. PANTONE colors
@@ -70,8 +73,10 @@
#include "gzstate.h"
#include "malloc_.h"
#include "gsutil.h"
+#include "gxcie.h"
#include "gsncdummy.h"
+
#if ENABLE_CUSTOM_COLOR_CALLBACK /* Defined in src/gsnamecl.h */
/*
@@ -151,40 +156,6 @@
}
/*
- * Dummy convert routine for simple color spaces (gray, RGB, CMYK, DeviceN,
- * and Separation) which are not handled by the client.
- */
-static int
-client_remap_simple_no_op(client_custom_color_params_t * pparams,
- const frac * pconc, const gs_color_space * pcs, gx_device_color * pdc,
- const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
-{
- /*
- * Returning an error value will cause GS to use its normal processes
- * for handling the color space.
- */
- return_error(gs_error_rangecheck);
-}
-
-/*
- * Dummy convert routine for complex color spaces (CIEBasedA, CIEBasedABC,
- * CIEBasedDEF, CIEBasedDEF, CIEBasedDEFG, ICCBased) which are not handled
- * by the client.
- */
-static int
-client_remap_complex_no_op(client_custom_color_params_t * pparams,
- const gs_client_color * pc, const gs_color_space * pcs,
- gx_device_color * pdc, const gs_imager_state * pis, gx_device * dev,
- gs_color_select_t select)
-{
- /*
- * Returning an error value will cause GS to use its normal processes
- * for handling the color space.
- */
- return_error(gs_error_rangecheck);
-}
-
-/*
* Since this is an example for a client, we are using the system
* malloc and free routines instead of the normal GS memory management
* routines.
@@ -525,7 +496,9 @@
pdc, pis, dev, select, gs_color_space_num_components(pcs));
}
-#if OBJECT_TYPE_EXAMPLE
+
+#if !PANTONE_ONLY
+
/*
* Install a DeviceGray color space.
*/
@@ -577,13 +550,24 @@
const frac * pconc, const gs_color_space * pcs, gx_device_color * pdc,
const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
{
- /*
- * For demo and debug purposes, make our colors a function of the
- * intensity of the given colors and the object type.
- */
- frac intensity = pconc[0];
- convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+ #if OBJECT_TYPE_EXAMPLE
+
+ /* For demo and debug purposes, make our colors a function of the
+ * intensity of the given colors and the object type. */
+
+ frac intensity = pconc[0];
+ convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+
+ #else
+
+ /* If desired, replace with your own color transformation */
+
+ gx_remap_concrete_gray(pconc[0], pdc, pis, dev, select);
+
+ #endif
+
+
return 0;
}
@@ -607,13 +591,23 @@
const frac * pconc, const gs_color_space * pcs, gx_device_color * pdc,
const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
{
- /*
- * For demo and debug purposes, make our colors a function of the
- * intensity of the given colors and the object type.
- */
- frac intensity = (frac)(pconc[0] * 0.30 + pconc[1] * 0.59 + pconc[2] * 0.11);
- convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+ #if OBJECT_TYPE_EXAMPLE
+
+ /* For demo and debug purposes, make our colors a function of the
+ * intensity of the given colors and the object type. */
+
+ frac intensity = (frac)(pconc[0] * 0.30 + pconc[1] * 0.59 + pconc[2] * 0.11);
+ convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+
+ #else
+
+ /* If desired, replace with your own color transformation */
+
+ gx_remap_concrete_rgb(pconc[0], pconc[1], pconc[2], pdc, pis, dev, select);
+
+ #endif
+
return 0;
}
@@ -636,16 +630,27 @@
const frac * pconc, const gs_color_space * pcs, gx_device_color * pdc,
const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
{
- /*
- * For demo and debug purposes, make our colors a function of the
- * intensity of the given colors and the object type.
- */
- frac intensity = frac_1 - (frac)(pconc[0] * 0.30 + pconc[1] * 0.59
- + pconc[2] * 0.11 + pconc[3]);
- if (intensity < frac_0)
- intensity = frac_0;
- convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+ #if OBJECT_TYPE_EXAMPLE
+
+ /*
+ * For demo and debug purposes, make our colors a function of the
+ * intensity of the given colors and the object type. */
+
+ frac intensity = frac_1 - (frac)(pconc[0] * 0.30 + pconc[1] * 0.59
+ + pconc[2] * 0.11 + pconc[3]);
+
+ if (intensity < frac_0)
+ intensity = frac_0;
+ convert_intensity_into_device_color(intensity, pdc, pis, dev, select);
+
+ #else
+
+ /* If desired, replace with your own color transformation */
+ gx_remap_concrete_cmyk(pconc[0], pconc[1], pconc[2], pconc[3],pdc, pis, dev, select);
+
+ #endif
+
return 0;
}
@@ -764,23 +769,47 @@
return true;
}
+
+
client_install_ICCtoXYZ(client_custom_color_params_t * pparams,
gs_color_space * pcs, gs_state * pgs)
{
int code;
const gs_icc_params * picc_params = (const gs_icc_params *)&pcs->params.icc;
gs_cie_icc * picc_info = picc_params->picc_info;
+ demo_color_space_data_t * pdata;
- /* update the stub information used by the joint caches */
+ if (pcs->pclient_color_space_data != NULL)
+ return true;
+
+ pdata = allocate_client_data_block(1, pcs->rc.memory->stable_memory);
+ pcs->pclient_color_space_data = (client_color_space_data_t *) pdata;
+
+ /* Need to initialize the client data. The imager_state is what is needed in pdata->CIEtoXZY_ps */
+
+ /* update the stub information used by the joint caches */
gx_cie_load_common_cache(&picc_info->common, pgs);
gx_cie_common_complete(&picc_info->common);
+
if ((code=gs_cie_cs_complete(pgs, true)) < 0) {
- client_adjust_cspace_count(pcs, -1); /* free it up */
+ client_adjust_cspace_count(pcs, -1); /* free it up */
return false;
}
+
+ /* Now allocate the conversion imager state in stable_memory */
+ /* so that the garbage collector won't free it */
+ code = gx_cie_to_xyz_alloc(&pdata->CIEtoXYZ_pis, pcs,
+ pcs->rc.memory->stable_memory);
+
+ if (code < 0) {
+ client_adjust_cspace_count(pcs, -1); /* free it up */
+ return false;
+ }
+
return true;
}
+
/*
* Convert a CIEBasedA color into device color.
*/
@@ -794,7 +823,6 @@
(demo_color_space_data_t *)(pcs->pclient_color_space_data);
frac gray = convert2frac(pc->paint.values[0], pcs->params.a->RangeA);
-
/*** Demonstrate method to convert to XYZ ***/
if (pdata->CIEtoXYZ_pis) {
frac xyz[3];
@@ -941,16 +969,18 @@
int i, num_values = pcs->params.icc.picc_info->num_components;
/*** Demonstrate method to convert to XYZ ***/
- if (pdata->CIEtoXYZ_pis) {
- frac xyz[3];
+ if (pdata->CIEtoXYZ_pis) {
- cs_concretize_color(pc, pcs, xyz, pdata->CIEtoXYZ_pis);
- /* We don't really do anything with these values, but this */
- /* is where a real client could convert to a device color */
- if_debug6('|', "[c]client_remap ICCBased [%g, %g, %g] -> XYZ [%g, %g, %g]\n",
- pc->paint.values[0], pc->paint.values[1], pc->paint.values[2],
- frac2float(xyz[0]), frac2float(xyz[1]), frac2float(xyz[2]));
+ frac xyz[3];
+
+ cs_concretize_color(pc, pcs, xyz, pdata->CIEtoXYZ_pis);
+ /* We don't really do anything with these values, but this */
+ /* is where a real client could convert to a device color */
+ if_debug6('|', "[c]client_remap ICCBased [%g, %g, %g] -> XYZ [%g, %g, %g]\n",
+ pc->paint.values[0], pc->paint.values[1], pc->paint.values[2],
+ frac2float(xyz[0]), frac2float(xyz[1]), frac2float(xyz[2]));
}
+
/*
* For demo and debug purposes, make our colors a function of the
* intensity of the given color value and the object type. The color
@@ -980,9 +1010,40 @@
#undef convert2frac
-#endif /* OBJECT_TYPE_EXAMPLE */
+#endif /* NOT PANTONE_ONLY */
-#if OBJECT_TYPE_EXAMPLE
+#if PANTONE_ONLY
+
+ /*
+ * For PANTONE colors, we only need to handle Separation and DeviceN
+ * color spaces. These are the only color spaces that can have PANTONE
+ * colors.
+ */
+ client_custom_color_procs_t demo_procs = {
+ client_install_no_op, /* DeviceGray */
+ NULL,
+ client_install_no_op, /* DeviceRGB */
+ NULL,
+ client_install_no_op, /* DeviceCMYK */
+ NULL,
+ client_pantone_install_Separation, /* Separation */
+ client_pantone_remap_Separation,
+ client_pantone_install_DeviceN, /* DeviceN */
+ client_pantone_remap_DeviceN,
+ client_install_no_op, /* CIEBasedA */
+ NULL,
+ client_install_no_op, /* CIEBasedABC */
+ NULL,
+ client_install_no_op, /* CIEBasedDEF */
+ NULL,
+ client_install_no_op, /* CIEBasedDEFG */
+ NULL,
+ client_install_no_op, /* ICCBased */
+ NULL
+ };
+
+#else /* Not PANTONE_ONLY special */
+
/*
* Client call back procedures for our demo which illustrates color
* processing based upon object type.
@@ -1009,34 +1070,11 @@
client_install_ICCtoXYZ, /* ICCBased */
client_remap_ICCBased
};
-#else /* Not OBJECT_TYPE_EXAMPLE special */
-/*
- * For PANTONE colors, we only need to handle Separation and DeviceN
- * color spaces. These are the only color spaces that can have PANTONE
- * colors.
- */
-client_custom_color_procs_t demo_procs = {
- client_install_no_op, /* DeviceGray */
- client_remap_simple_no_op,
- client_install_no_op, /* DeviceRGB */
- client_remap_simple_no_op,
- client_install_no_op, /* DeviceCMYK */
- client_remap_simple_no_op,
- client_pantone_install_Separation, /* Separation */
- client_pantone_remap_Separation,
- client_pantone_install_DeviceN, /* DeviceN */
- client_pantone_remap_DeviceN,
- client_install_no_op, /* CIEBasedA */
- client_remap_complex_no_op,
- client_install_no_op, /* CIEBasedABC */
- client_remap_complex_no_op,
- client_install_no_op, /* CIEBasedDEF */
- client_remap_complex_no_op,
- client_install_no_op, /* CIEBasedDEFG */
- client_remap_complex_no_op,
- client_install_no_op, /* ICCBased */
- client_remap_complex_no_op
-};
-#endif /* OBJECT_TYPE_EXAMPLE */
+#endif /* PANTONE_ONLY_EXAMPLE */
+
#endif /* ENABLE_CUSTOM_COLOR_CALLBACK */
+
+
+
+
Modified: trunk/gs/src/gxcmap.c
===================================================================
--- trunk/gs/src/gxcmap.c 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/gxcmap.c 2008-04-30 04:51:02 UTC (rev 8679)
@@ -28,6 +28,7 @@
#include "gxdither.h"
#include "gxcdevn.h"
#include "string_.h"
+#include "gsnamecl.h" /* Custom color call back define */
/* Structure descriptor */
public_st_device_color();
Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak 2008-04-30 01:35:18 UTC (rev 8678)
+++ trunk/gs/src/lib.mak 2008-04-30 04:51:02 UTC (rev 8679)
@@ -577,7 +577,7 @@
$(GLOBJ)gxcmap.$(OBJ) : $(GLSRC)gxcmap.c $(GXERR)\
$(gsccolor_h)\
$(gxalpha_h) $(gxcspace_h) $(gxfarith_h) $(gxfrac_h)\
- $(gxdcconv_h) $(gxdevice_h) $(gxcmap_h) $(gxlum_h)\
+ $(gxdcconv_h) $(gxdevice_h) $(gxcmap_h) $(gsnamecl_h) $(gxlum_h)\
$(gzstate_h) $(gxdither_h) $(gxcdevn_h) $(string__h)
$(GLCC) $(GLO_)gxcmap.$(OBJ) $(C_) $(GLSRC)gxcmap.c
@@ -772,7 +772,7 @@
$(GLOBJ)gscspace.$(OBJ) : $(GLSRC)gscspace.c $(GXERR) $(memory__h)\
$(gsstruct_h) $(gsccolor_h) $(gsutil_h)\
$(gxcmap_h) $(gxcspace_h) $(gxistate_h) $(gsovrc_h) $(gsstate_h)\
- $(gsdevice_h) $(gxdevcli_h) $(gzstate_h) $(stream_h)
+ $(gsdevice_h) $(gxdevcli_h) $(gzstate_h) $(gsnamecl_h) $(stream_h)
$(GLCC) $(GLO_)gscspace.$(OBJ) $(C_) $(GLSRC)gscspace.c
$(GLOBJ)gscicach.$(OBJ) : $(GLSRC)gscicach.c $(GXERR)\
@@ -2438,12 +2438,12 @@
$(GLCC) $(GLO_)gscsepr.$(OBJ) $(C_) $(GLSRC)gscsepr.c
$(GLOBJ)gsnamecl.$(OBJ) : $(GLSRC)gsnamecl.c $(GXERR) $(memory__h) $(gxcspace_h)\
- $(gscdefs_h) $(gxdevice_h) $(gzstate_h)
+ $(gscdefs_h) $(gxdevice_h) $(gsnamecl_h) $(gzstate_h)
$(GLCC) $(GLO_)gsnamecl.$(OBJ) $(C_) $(GLSRC)gsnamecl.c
$(GLOBJ)gsncdummy.$(OBJ) : $(GLSRC)gsncdummy.c $(GXERR) $(math__h)\
$(memory__h) $(malloc__h) $(gscdefs_h) $(gscspace_h) $(gscie_h)\
- $(gsicc_h) $(gxdevice_h) $(gzstate_h) $(gsutil_h) $(gsncdummy_h)
+ $(gsicc_h) $(gxdevice_h) $(gzstate_h) $(gsutil_h) $(gxcie_h) $(gsncdummy_h)
$(GLCC) $(GLO_)gsncdummy.$(OBJ) $(C_) $(GLSRC)gsncdummy.c
# ================ Display Postscript extensions ================ #
@@ -2492,7 +2492,7 @@
$(GLOBJ)gscdevn.$(OBJ) : $(GLSRC)gscdevn.c $(GXERR) $(memory__h) $(string__h)\
$(gscdevn_h) $(gsfunc_h) $(gsmatrix_h) $(gsrefct_h) $(gsstruct_h)\
- $(gxcspace_h) $(gxcdevn_h) $(gxfarith_h) $(gxfrac_h) $(gxcmap_h)\
+ $(gxcspace_h) $(gxcdevn_h) $(gxfarith_h) $(gxfrac_h) $(gsnamecl_h) $(gxcmap_h)\
$(gxistate_h) $(gscoord_h) $(gzstate_h) $(gxdevcli_h) $(gsovrc_h) $(stream_h)
$(GLCC) $(GLO_)gscdevn.$(OBJ) $(C_) $(GLSRC)gscdevn.c
More information about the gs-cvs
mailing list