[gs-cvs] rev 8677 - trunk/gs/src
mvrhel at ghostscript.com
mvrhel at ghostscript.com
Mon Apr 28 23:34:18 PDT 2008
Author: mvrhel
Date: 2008-04-28 23:34:17 -0700 (Mon, 28 Apr 2008)
New Revision: 8677
Modified:
trunk/gs/src/gxicolor.c
trunk/gs/src/lib.mak
Log:
Fix for bug 689806 which was introduced when fixing bug 689803. The current bug was related to a CIELAB image with a colorspace ICC profile (LAB to LAB). The image data was incorrectly being normalized between 0 and 1 (float). It is now properly normalized to the range of the CIELAB ICC space. There still exists an issue with this file as absolute colorimetry should be used. This is the source of the current difference between AR and GS. However, the image is no longer black now but should match the GS result prior to rev 8664.
Modified: trunk/gs/src/gxicolor.c
===================================================================
--- trunk/gs/src/gxicolor.c 2008-04-29 06:04:18 UTC (rev 8676)
+++ trunk/gs/src/gxicolor.c 2008-04-29 06:34:17 UTC (rev 8677)
@@ -13,6 +13,7 @@
/* $Id$ */
/* Color image rendering */
+
#include "gx.h"
#include "memory_.h"
#include "gpcheck.h"
@@ -32,6 +33,8 @@
#include "gxdevmem.h"
#include "gxcpath.h"
#include "gximage.h"
+#include "icc.h"
+#include "gsicc.h"
typedef union {
byte v[GS_IMAGE_MAX_COLOR_COMPONENTS];
@@ -142,6 +145,7 @@
const byte *bufend = psrc + w;
bool use_cache = spp * penum->bps <= 12;
int code = 0, mcode = 0;
+ gs_cie_icc * picc_info; /*used for detecting if image source color space is CIELAB. */
if (h == 0)
return 0;
@@ -242,13 +246,51 @@
}
decode_sample(next.v[3], cc, 3);
if_debug1('B', "[B]cc[3]=%g\n", cc.paint.values[3]);
-do3: decode_sample(next.v[0], cc, 0);
- decode_sample(next.v[1], cc, 1);
- decode_sample(next.v[2], cc, 2);
+do3: if(spp == 3 && pcs->type->index == gs_color_space_index_CIEICC)
+ {
+ /* It is 3 channel with an ICC profile.
+ We need to check if it is an LAB image */
+
+ picc_info = pcs->params.icc.picc_info;
+
+ if( picc_info->plu->e_inSpace == icSigLabData )
+ {
+
+ /* It is a CIELAB image. For now, put in true CIELAB float values rather than normalized 0 to 1 floats */
+ /* concretization will handle the proper conversion this way */
+
+ decode_sample(next.v[0], cc, 0);
+ cc.paint.values[0]*=100.0;
+ decode_sample(next.v[1], cc, 1);
+ cc.paint.values[1] = 255.0*cc.paint.values[1] - 128.0;
+ decode_sample(next.v[2], cc, 2);
+ cc.paint.values[2] = 255.0*cc.paint.values[2] - 128.0;
+
+ } else {
+
+ /* To floats */
+
+ decode_sample(next.v[0], cc, 0);
+ decode_sample(next.v[1], cc, 1);
+ decode_sample(next.v[2], cc, 2);
+
+ }
+
+ } else {
+
+ /* To floats */
+
+ decode_sample(next.v[0], cc, 0);
+ decode_sample(next.v[1], cc, 1);
+ decode_sample(next.v[2], cc, 2);
+
+ }
+
if_debug3('B', "[B]cc[0..2]=%g,%g,%g\n",
cc.paint.values[0], cc.paint.values[1],
cc.paint.values[2]);
- } else if (spp == 3) { /* may be RGB */
+
+ } else if (spp == 3) { /* may be RGB, but could be LAB image file with ICC profile... */
next.v[0] = psrc[0];
next.v[1] = psrc[1];
next.v[2] = psrc[2];
@@ -275,18 +317,20 @@
goto mapped;
}
if (device_color) {
- frac frac_color[3];
- /*
- * We can call the remap concrete_color for the colorspace
- * directly since device_color is only true if the colorspace
- * is concrete.
- */
- frac_color[0] = byte2frac(next.v[0]);
- frac_color[1] = byte2frac(next.v[1]);
- frac_color[2] = byte2frac(next.v[2]);
- remap_concrete_color(frac_color, pcs, pdevc_next, pis,
- dev, gs_color_select_source);
- goto mapped;
+
+ frac frac_color[3];
+ /*
+ * We can call the remap concrete_color for the colorspace
+ * directly since device_color is only true if the colorspace
+ * is concrete.
+ */
+ frac_color[0] = byte2frac(next.v[0]);
+ frac_color[1] = byte2frac(next.v[1]);
+ frac_color[2] = byte2frac(next.v[2]);
+ remap_concrete_color(frac_color, pcs, pdevc_next, pis,
+ dev, gs_color_select_source);
+ goto mapped;
+
}
goto do3;
} else if (penum->alpha) {
Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak 2008-04-29 06:04:18 UTC (rev 8676)
+++ trunk/gs/src/lib.mak 2008-04-29 06:34:17 UTC (rev 8677)
@@ -2259,7 +2259,7 @@
$(gxdevice_h) $(gxdevmem_h) $(gxfixed_h) $(gxfrac_h)\
$(gximage_h) $(gxistate_h) $(gxmatrix_h)\
$(gzstate_h)
- $(GLCC) $(GLO_)gxicolor.$(OBJ) $(C_) $(GLSRC)gxicolor.c
+ $(GLICCCC) $(GLO_)gxicolor.$(OBJ) $(C_) $(GLSRC)gxicolor.c
# ---- Level 1 path miscellany (arcs, pathbbox, path enumeration) ---- #
More information about the gs-cvs
mailing list