[gs-cvs] gs/src

Ralph Giles giles at ghostscript.com
Tue Jul 12 17:39:52 PDT 2005


Update of /cvs/ghostscript/gs/src
In directory casper2:/tmp/cvs-serv20015/src

Modified Files:
	gxcmap.c 
Log Message:
Cast color components to type gx_color_index before shifting when
composing a chunked index color in gx_default_rgb_map_rgb_color().
Partial fix for bug 688204.

DETAILS:

Without the explicit casts, color components were only promoted to
the default int type before the shifts were applied. On 32 bit machines
this means that 16 bpc output generated nonsense, shifting the high
channel entirely out of the word, and only promoting to a 64 bit type
on assignment. With the explicit casts, the promotion to a 64 bit type
(assuming a 64 bit gx_color_index) happens first so that the shift logic
is correct for deep devices.

With this change the "24 bit RGB" default mapping works for 48 bit
color as well as for other spaces in-between. 24 bits remains special
cased; rough benchmarking showed no significant advantage to special 
casing 48 bits as well.


Index: gxcmap.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxcmap.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- gxcmap.c	5 May 2005 05:35:22 -0000	1.25
+++ gxcmap.c	13 Jul 2005 00:39:50 -0000	1.26
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
+/* Copyright (C) 1992-2005 artofcode LLC. All rights reserved.
   
   This software is provided AS-IS with no warranty, either express or
   implied.
@@ -1367,8 +1367,9 @@
     else {
 	int bpc = dev->color_info.depth / 3;
 	int drop = sizeof(gx_color_value) * 8 - bpc;
-
-	return ((((cv[0] >> drop) << bpc) + (cv[1] >> drop)) << bpc) + (cv[2] >> drop);
+	return ( ( (((gx_color_index)cv[0] >> drop) << bpc) +
+		    ((gx_color_index)cv[1] >> drop)         ) << bpc) + 
+	       ((gx_color_index)cv[2] >> drop);
     }
 }
 



More information about the gs-cvs mailing list