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

mvrhel at ghostscript.com mvrhel at ghostscript.com
Fri Apr 25 21:35:57 PDT 2008


Author: mvrhel
Date: 2008-04-25 21:35:56 -0700 (Fri, 25 Apr 2008)
New Revision: 8664

Modified:
   trunk/gs/src/gsicc.c
   trunk/gs/src/int.mak
   trunk/gs/src/zicc.c
Log:
Fix for bug#689803.  Set bounds correctly when input data is LAB and color also includes a colorspace source profile (e.g. LAB to LAB).  

Modified: trunk/gs/src/gsicc.c
===================================================================
--- trunk/gs/src/gsicc.c	2008-04-25 19:24:16 UTC (rev 8663)
+++ trunk/gs/src/gsicc.c	2008-04-26 04:35:56 UTC (rev 8664)
@@ -28,7 +28,6 @@
 #include "icc.h"		/* must precede icc.h */
 #include "gsicc.h"
 
-
 typedef struct _icmFileGs icmFileGs;
 
 struct _icmFileGs {
@@ -117,6 +116,7 @@
 static cs_proc_concretize_color(gx_concretize_CIEICC);
 #if ENABLE_CUSTOM_COLOR_CALLBACK
 static cs_proc_remap_color(gx_remap_ICCBased);
+static cs_proc_has_clientcallback(gx_has_clientcallback_ICCBased);
 #endif
 static cs_proc_final(gx_final_CIEICC);
 static cs_proc_serialize(gx_serialize_CIEICC);
@@ -133,7 +133,7 @@
     gx_concretize_CIEICC,           /* concreteize_color */
     NULL,                           /* remap_concrete_color */
 #if ENABLE_CUSTOM_COLOR_CALLBACK
-    gx_remap_ICCBased,		    /* remap_color */
+    gx_remap_ICCBased,				/* remap_color */
 #else
     gx_default_remap_color,         /* remap_color */
 #endif
@@ -143,6 +143,10 @@
     gx_no_adjust_color_count,       /* adjust_color_count */
     gx_serialize_CIEICC,		    /* serialize */
     gx_cspace_is_linear_default
+#if ENABLE_CUSTOM_COLOR_CALLBACK
+	,
+	gx_has_clientcallback_ICCBased
+#endif
 };
 
 
@@ -253,21 +257,26 @@
     gx_restrict_CIEICC(&lcc, pcs);
     for (i = 0; i < ncomps; i++)
         inv[i] = lcc.paint.values[i];
+		
+	/* Since the original limits were wrong for this case, We need to adjust things a bit different */
 
     /* For input Lab color space massage the values into Lab range */
 
-    if (picc_info->plu->e_inSpace == icSigLabData) {
+   /* if (picc_info->plu->e_inSpace == icSigLabData) {
+
         inv[0] *= 100;
         inv[1] = inv[1]*255 - 128;
         inv[2] = inv[2]*255 - 128; 
-    }
 
+    } */
+
     /*
      * Perform the lookup operation. A return value of 1 indicates that
      * clipping occurred somewhere in the operation, but the result is
      * legitimate. Other non-zero return values indicate an error, which
      * should not occur in practice.
      */
+
     if (picc_info->plu->lookup(picc_info->plu, outv, inv) > 1)
         return_error(gs_error_unregistered);
 
@@ -278,8 +287,8 @@
 
 
         f[1] = (outv[0] + 16.0) / 116.0;
-        f[0] = f[1] + outv[1] / 500.0;
-        f[2] = f[1] - outv[2] / 200;
+        f[0] = f[1] + (outv[1]) / 500.0;
+        f[2] = f[1] - (outv[2]) / 200;
 
         for (i = 0; i < 3; i++) {
             if (f[i] >= 6.0 / 29.0)
@@ -322,7 +331,7 @@
     client_custom_color_params_t * pcb =
 	    (client_custom_color_params_t *) (pis->custom_color_callback);
 
-    if (pcb != NULL) {
+    if (pcb != NULL && pcb->client_procs->remap_ICCBased != NULL ) {
 	if (pcb->client_procs->remap_ICCBased(pcb, pc, pcs,
 			   			pdc, pis, dev, select) == 0)
 	    return 0;
@@ -330,6 +339,16 @@
     /* Use default routine for non custom color processing. */
     return gx_default_remap_color(pc, pcs, pdc, pis, dev, select);
 }
+
+/* Determine if the user has installed a callback for this colorspace or not */
+static bool gx_has_clientcallback_ICCBased( const gs_imager_state * pis )
+{
+    client_custom_color_params_t * pcb =
+	    (client_custom_color_params_t *) (pis->custom_color_callback);
+
+    return (pcb != NULL && pcb->client_procs->remap_ICCBased != NULL );
+}
+
 #endif
 
 /*

Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak	2008-04-25 19:24:16 UTC (rev 8663)
+++ trunk/gs/src/int.mak	2008-04-26 04:35:56 UTC (rev 8664)
@@ -1817,7 +1817,7 @@
 $(PSOBJ)zicc.$(OBJ) : $(PSSRC)zicc.c  $(OP) $(math__h) $(memory__h)\
  $(gsstruct_h) $(gxcspace_h) $(stream_h) $(files_h) $(gscolor2_h)\
  $(gsicc_h) $(estack_h) $(idict_h) $(idparam_h) $(igstate_h) $(icie_h)
-	$(PSCC) $(PSO_)zicc.$(OBJ) $(C_) $(PSSRC)zicc.c
+	$(GLICCCC) $(PSO_)zicc.$(OBJ) $(C_) $(PSSRC)zicc.c
 
 # ---------------- Support for %disk IODevices ---------------- #
 

Modified: trunk/gs/src/zicc.c
===================================================================
--- trunk/gs/src/zicc.c	2008-04-25 19:24:16 UTC (rev 8663)
+++ trunk/gs/src/zicc.c	2008-04-26 04:35:56 UTC (rev 8664)
@@ -23,6 +23,7 @@
 #include "stream.h"
 #include "files.h"
 #include "gscolor2.h"
+#include "icc.h"			
 #include "gsicc.h"
 #include "estack.h"
 #include "idict.h"
@@ -31,6 +32,7 @@
 #include "icie.h"
 #include "ialloc.h"
 
+
 /*
  *   <dict>  .seticcspace  -
  *
@@ -141,6 +143,39 @@
     rc_increment(palt_cs);
 
     code = gx_load_icc_profile(picc_info);
+
+	/* If the input space to this profile is CIELAB, then we need to adjust the limits */
+	/* See ICC spec ICC.1:2004-10 Section 6.3.4.2 and 6.4 */
+	if(picc_info->plu->e_inSpace == icSigLabData)
+	{
+        picc_info->Range.ranges[0].rmin = 0.0;
+        picc_info->Range.ranges[0].rmax = 100.0;
+
+        picc_info->Range.ranges[1].rmin = -128.0;
+        picc_info->Range.ranges[1].rmax = 127.0;
+
+        picc_info->Range.ranges[2].rmin = -128.0;
+        picc_info->Range.ranges[2].rmax = 127.0;
+
+	} 
+
+	/* If the input space is icSigXYZData, then we should do the limits based upon the white point of the profile.  */
+
+	if(picc_info->plu->e_inSpace == icSigXYZData)
+	{
+		for (i = 0; i < 3; i++) 
+		{
+
+			picc_info->Range.ranges[i].rmin = 0;
+
+		}
+
+		picc_info->Range.ranges[0].rmax = picc_info->common.points.WhitePoint.u;
+		picc_info->Range.ranges[1].rmax = picc_info->common.points.WhitePoint.v;
+		picc_info->Range.ranges[2].rmax = picc_info->common.points.WhitePoint.w;
+
+	}
+
     if (code < 0)
 	return code;
 



More information about the gs-cvs mailing list