[gs-cvs] rev 8781 - trunk/gs/src

mvrhel at ghostscript.com mvrhel at ghostscript.com
Tue May 27 17:27:24 PDT 2008


Author: mvrhel
Date: 2008-05-27 17:27:23 -0700 (Tue, 27 May 2008)
New Revision: 8781

Modified:
   trunk/gs/src/gsciemap.c
   trunk/gs/src/gscolor2.c
   trunk/gs/src/gscolor2.h
   trunk/gs/src/gxcie.h
   trunk/gs/src/lib.mak
Log:
Fix to enable proper custom color callback when indexed images with ICC profiles are used.  Bug 689863.

Modified: trunk/gs/src/gsciemap.c
===================================================================
--- trunk/gs/src/gsciemap.c	2008-05-27 20:12:08 UTC (rev 8780)
+++ trunk/gs/src/gsciemap.c	2008-05-28 00:27:23 UTC (rev 8781)
@@ -22,6 +22,7 @@
 #include "gxdevice.h"		/* for gxcmap.h */
 #include "gxcmap.h"
 #include "gxistate.h"
+#include "gscolor2.h"
 
 /*
  * Compute a cache index as (vin - base) * factor.
@@ -317,6 +318,53 @@
     /* Use default routine for non custom color processing. */
     return gx_default_remap_color(pc, pcs, pdc, pis, dev, select);
 }
+
+
+/* Render an Indexed color.
+ * This routine is only used if ENABLE_CUSTOM_COLOR_CALLBACK is true.
+ * Otherwise we use gx_default_remap_color directly for Indexed color
+ * spaces.
+ */
+
+int
+gx_remap_IndexedSpace(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)
+{
+
+    const gs_color_space *pbcs;
+    int code;
+    gs_client_color cc;
+    client_custom_color_params_t * pcb =
+	    (client_custom_color_params_t *) (pis->memory->gs_lib_ctx->custom_color_callback);
+
+    if (pcb != NULL) {
+
+        /* First handle all the index look up stuff  */
+
+        code = gs_indexed_limit_and_lookup(pc, pcs, &cc);
+
+        if (code < 0)
+        {
+	    return code;
+
+        }
+
+        /* We can either have a switch here to pick the proper call back process 
+           or go ahead and have the remap call do it.  For now do the later. */
+
+        pbcs = (const gs_color_space *)pcs->base_space;
+
+        if( pbcs->type->remap_color(&cc, pbcs,
+                                pdc, pis, dev, select) == 0 )                               
+                                return(0);
+
+    }
+
+    /* Use default routine for non custom color processing. */
+    return gx_default_remap_color(pc, pcs, pdc, pis, dev, select);
+}
+
 #endif
 
 /* Render a CIEBasedABC color. */

Modified: trunk/gs/src/gscolor2.c
===================================================================
--- trunk/gs/src/gscolor2.c	2008-05-27 20:12:08 UTC (rev 8780)
+++ trunk/gs/src/gscolor2.c	2008-05-28 00:27:23 UTC (rev 8781)
@@ -24,6 +24,7 @@
 #include "gzstate.h"
 #include "gxpcolor.h"
 #include "stream.h"
+#include "gxcie.h"  
 
 /* ---------------- General colors and color spaces ---------------- */
 
@@ -166,7 +167,12 @@
     gx_init_paint_1, gx_restrict_Indexed,
     gx_concrete_space_Indexed,
     gx_concretize_Indexed, NULL,
-    gx_default_remap_color, gx_install_Indexed,
+#if ENABLE_CUSTOM_COLOR_CALLBACK
+    gx_remap_IndexedSpace,
+#else
+    gx_default_remap_color,
+#endif
+    gx_install_Indexed,
     gx_set_overprint_Indexed,
     gx_final_Indexed, gx_no_adjust_color_count,
     gx_serialize_Indexed,
@@ -425,15 +431,11 @@
 gx_concretize_Indexed(const gs_client_color * pc, const gs_color_space * pcs,
 		      frac * pconc, const gs_imager_state * pis)
 {
-    float value = pc->paint.values[0];
-    int index =
-	(is_fneg(value) ? 0 :
-	 value >= pcs->params.indexed.hival ? pcs->params.indexed.hival :
-	 (int)value);
+
+    gs_client_color cc;
     const gs_color_space *pbcs =
 	(const gs_color_space *)pcs->base_space;
-    gs_client_color cc;
-    int code = gs_cspace_indexed_lookup(pcs, index, &cc);
+   int code = gs_indexed_limit_and_lookup(pc, pcs, &cc);
 
     if (code < 0)
 	return code;
@@ -475,6 +477,23 @@
     }
 }
 
+/* Look up with restriction */
+
+int
+gs_indexed_limit_and_lookup(const gs_client_color * pc,const gs_color_space *pcs,
+			 gs_client_color *pcc)
+{     
+  
+    float value = pc->paint.values[0];
+        int index =
+	    (is_fneg(value) ? 0 :
+	     value >= pcs->params.indexed.hival ? pcs->params.indexed.hival :
+	     (int)value);
+         return(gs_cspace_indexed_lookup(pcs, index, pcc));
+
+}
+
+
 /* ---------------- Serialization. -------------------------------- */
 
 static int 

Modified: trunk/gs/src/gscolor2.h
===================================================================
--- trunk/gs/src/gscolor2.h	2008-05-27 20:12:08 UTC (rev 8780)
+++ trunk/gs/src/gscolor2.h	2008-05-28 00:27:23 UTC (rev 8781)
@@ -35,7 +35,12 @@
 const gs_client_color *gs_currentcolor(const gs_state *);
 int gs_setcolor(gs_state *, const gs_client_color *);
 
+/* Look up with restriction */
+int
+gs_indexed_limit_and_lookup(const gs_client_color * pc,const gs_color_space *pcs,
+			 gs_client_color *pcc);
 
+
 /* CIE-specific routines */
 #ifndef gs_cie_render_DEFINED
 #  define gs_cie_render_DEFINED

Modified: trunk/gs/src/gxcie.h
===================================================================
--- trunk/gs/src/gxcie.h	2008-05-27 20:12:08 UTC (rev 8780)
+++ trunk/gs/src/gxcie.h	2008-05-28 00:27:23 UTC (rev 8781)
@@ -91,6 +91,7 @@
 cs_proc_remap_color(gx_remap_CIEDEFG);
 cs_proc_remap_color(gx_remap_CIEDEF);
 cs_proc_remap_color(gx_remap_CIEA);
+cs_proc_remap_color(gx_remap_IndexedSpace);
 #endif
 cs_proc_remap_color(gx_remap_CIEABC);
 cs_proc_concretize_color(gx_concretize_CIEA);

Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak	2008-05-27 20:12:08 UTC (rev 8780)
+++ trunk/gs/src/lib.mak	2008-05-28 00:27:23 UTC (rev 8781)
@@ -2294,7 +2294,7 @@
 
 $(GLOBJ)gscolor2.$(OBJ) : $(GLSRC)gscolor2.c $(GXERR) $(memory__h)\
  $(gxarith_h) $(gxfixed_h) $(gxmatrix_h) $(gxcspace_h)\
- $(gxcolor2_h) $(gzstate_h) $(gxpcolor_h) $(stream_h)
+ $(gxcolor2_h) $(gzstate_h) $(gxpcolor_h) $(stream_h) $(gxcie_h)
 	$(GLCC) $(GLO_)gscolor2.$(OBJ) $(C_) $(GLSRC)gscolor2.c
 
 psl2lib_=$(GLOBJ)gxiscale.$(OBJ)
@@ -2397,7 +2397,8 @@
 	$(GLCC) $(GLO_)gscie.$(OBJ) $(C_) $(GLSRC)gscie.c
 
 $(GLOBJ)gsciemap.$(OBJ) : $(GLSRC)gsciemap.c $(GXERR) $(math__h)\
- $(gxarith_h) $(gxcie_h) $(gxcmap_h) $(gxcspace_h) $(gxdevice_h) $(gxistate_h)
+ $(gxarith_h) $(gxcie_h) $(gxcmap_h) $(gxcspace_h) $(gxdevice_h) \
+ $(gxistate_h) $(gscolor2_h)
 	$(GLCC) $(GLO_)gsciemap.$(OBJ) $(C_) $(GLSRC)gsciemap.c
 
 $(GLOBJ)gscrd.$(OBJ) : $(GLSRC)gscrd.c $(GXERR)\



More information about the gs-cvs mailing list