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

alexcher at ghostscript.com alexcher at ghostscript.com
Sun Apr 27 22:20:54 PDT 2008


Author: alexcher
Date: 2008-04-27 22:20:54 -0700 (Sun, 27 Apr 2008)
New Revision: 8666

Modified:
   trunk/gs/src/gscspace.c
   trunk/gs/src/gxcmap.c
   trunk/gs/src/gxcspace.h
   trunk/gs/src/gxdevcli.h
   trunk/gs/src/lib.mak
Log:
Implement spacial handling of transfer functions during Gray to CMYK
conversion: ignore transfer functions for non-black components. Bug 688360.

DETAILS:
On this topic, section 7.3 of PRLM-3rd (page 494) says:
"Note: When the current color space is DeviceGray and the output device's
native color space is DeviceCMYK, the interpreter uses only the gray transfer 
function. ... This special case exists for compatibility with existing
applications." There is a similar comment in section 6.3 of the PDF 1.6
spec. (page 456).

DIFFERENCES:
None


Modified: trunk/gs/src/gscspace.c
===================================================================
--- trunk/gs/src/gscspace.c	2008-04-27 15:21:10 UTC (rev 8665)
+++ trunk/gs/src/gscspace.c	2008-04-28 05:20:54 UTC (rev 8666)
@@ -308,7 +308,9 @@
 /*
  * Determine if the current color model is a "DeviceCMYK" color model, and
  * if so what are its process color components. This information is required
- * only if overprint is true and overprint mode is set to 1.
+ * when PLRM defines special rules for CMYK devices. This includes:
+ * 1. DeviceGray to CMYK color conversion
+ * 2. when overprint is true and overprint mode is set to 1.
  *
  * A color model is considered a "DeviceCMYK" color model if it supports the
  * cyan, magenta, yellow, and black color components, and maps the DeviceCMYK
@@ -320,7 +322,7 @@
  * If the color model is a "DeviceCMYK" color model, return the set of
  * process color components; otherwise return 0.
  */
-static gx_color_index
+gx_color_index
 check_cmyk_color_model_comps(gx_device * dev)
 {
     gx_device_color_info *          pcinfo = &dev->color_info;
@@ -384,6 +386,7 @@
                    | ((gx_color_index)1 << black_c);
     pcinfo->opmode = GX_CINFO_OPMODE;
     pcinfo->process_comps = process_comps;
+    pcinfo->black_component = black_c;
     return process_comps;
 }
 

Modified: trunk/gs/src/gxcmap.c
===================================================================
--- trunk/gs/src/gxcmap.c	2008-04-27 15:21:10 UTC (rev 8665)
+++ trunk/gs/src/gxcmap.c	2008-04-28 05:20:54 UTC (rev 8666)
@@ -851,11 +851,25 @@
         for (i = 0; i < ncomps; i++)
             cm_comps[i] = gx_map_color_frac(pis,
 	    			cm_comps[i], effective_transfer[i]);
-    else
-        for (i = 0; i < ncomps; i++)
-            cm_comps[i] = frac_1 - gx_map_color_frac(pis,
+    else {
+        if (dev->color_info.opmode == GX_CINFO_OPMODE_UNKNOWN)
+            check_cmyk_color_model_comps(dev);  
+        if (dev->color_info.opmode == GX_CINFO_OPMODE) {  /* CMYK-like color space */
+            int k = dev->color_info.black_component;
+
+            for (i = 0; i < ncomps; i++) {
+                if (i == k)
+                    cm_comps[i] = frac_1 - gx_map_color_frac(pis,
 	    		(frac)(frac_1 - cm_comps[i]), effective_transfer[i]);
-
+                 else
+                    cm_comps[i] = cm_comps[i]; /* Ignore transfer, see PLRM3 p. 494 */
+            }
+        } else {
+            for (i = 0; i < ncomps; i++)
+                cm_comps[i] = frac_1 - gx_map_color_frac(pis,
+	    		    (frac)(frac_1 - cm_comps[i]), effective_transfer[i]);
+        }
+    }
     if (gx_render_device_DeviceN(cm_comps, pdc, dev, pis->dev_ht,
 	    				&pis->screen_phase[select]) == 1)
 	gx_color_load_select(pdc, pis, dev, select);
@@ -878,11 +892,25 @@
         for (i = 0; i < ncomps; i++)
             cv[i] = frac2cv(gx_map_color_frac(pis,
 	    			cm_comps[i], effective_transfer[i]));
-    else
-        for (i = 0; i < ncomps; i++)
-            cv[i] = frac2cv(frac_1 - gx_map_color_frac(pis,
+    else {
+        if (dev->color_info.opmode == GX_CINFO_OPMODE_UNKNOWN)
+            check_cmyk_color_model_comps(dev);  
+        if (dev->color_info.opmode == GX_CINFO_OPMODE) {  /* CMYK-like color space */
+            int k = dev->color_info.black_component;
+
+            for (i = 0; i < ncomps; i++) {
+                if (i == k)
+                    cv[i] = frac2cv(frac_1 - gx_map_color_frac(pis,
 	    		(frac)(frac_1 - cm_comps[i]), effective_transfer[i]));
-
+                else
+                    cv[i] = frac2cv(cm_comps[i]); /* Ignore transfer, see PLRM3 p. 494 */
+            }
+        } else {
+            for (i = 0; i < ncomps; i++)
+                cv[i] = frac2cv(frac_1 - gx_map_color_frac(pis,
+	    		    (frac)(frac_1 - cm_comps[i]), effective_transfer[i]));
+        }
+    }
     /* encode as a color index */
     color = dev_proc(dev, encode_color)(dev, cv);
 

Modified: trunk/gs/src/gxcspace.h
===================================================================
--- trunk/gs/src/gxcspace.h	2008-04-27 15:21:10 UTC (rev 8665)
+++ trunk/gs/src/gxcspace.h	2008-04-28 05:20:54 UTC (rev 8666)
@@ -22,6 +22,7 @@
 #include "gsccolor.h"
 #include "gscsel.h"
 #include "gxfrac.h"		/* for concrete colors */
+#include "gxcindex.h"           /* for gx_color_index  */
 
 /* Define opaque types. */
 
@@ -257,4 +258,8 @@
 gs_color_space *
 gs_cspace_alloc(gs_memory_t *mem, const gs_color_space_type *pcstype);
 
+/* Determine if the current color model is a "DeviceCMYK" color model, and */
+/* if so what are its process color components. */
+gx_color_index check_cmyk_color_model_comps(gx_device * dev);
+
 #endif /* gxcspace_INCLUDED */

Modified: trunk/gs/src/gxdevcli.h
===================================================================
--- trunk/gs/src/gxdevcli.h	2008-04-27 15:21:10 UTC (rev 8665)
+++ trunk/gs/src/gxdevcli.h	2008-04-28 05:20:54 UTC (rev 8666)
@@ -442,10 +442,12 @@
      *
      * If opmode has the value GX_CINFO_OPMODE, the process_comps will
      * be a bit mask, with the (1 << i) bit set if i'th component is the
-     * cyan, magenta, yellow, or black component.
+     * cyan, magenta, yellow, or black component and black_component will
+     * be set to the index of a black component.
      */
     gx_cm_opmode_t opmode;
     gx_color_index process_comps;
+    int black_component;
 } gx_device_color_info;
 
 /* NB encoding flag ignored */

Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak	2008-04-27 15:21:10 UTC (rev 8665)
+++ trunk/gs/src/lib.mak	2008-04-28 05:20:54 UTC (rev 8666)
@@ -436,7 +436,7 @@
 gxcolor2_h=$(GLSRC)gxcolor2.h\
  $(gscolor2_h) $(gsmatrix_h) $(gsrefct_h) $(gxbitmap_h)
 gxcspace_h=$(GLSRC)gxcspace.h\
- $(gscspace_h) $(gsccolor_h) $(gscsel_h) $(gxfrac_h)
+ $(gscspace_h) $(gsccolor_h) $(gscsel_h) $(gxfrac_h) $(gxcindex_h)
 gxht_h=$(GLSRC)gxht.h $(gsht1_h) $(gsrefct_h) $(gxhttype_h) $(gxtmap_h) $(gscspace_h)
 gxcie_h=$(GLSRC)gxcie.h $(gscie_h)
 gxpcolor_h=$(GLSRC)gxpcolor.h\



More information about the gs-cvs mailing list