[gs-cvs] rev 9343 - branches/smask_work/base
mvrhel at ghostscript.com
mvrhel at ghostscript.com
Fri Jan 9 22:01:49 PST 2009
Author: mvrhel
Date: 2009-01-09 22:01:49 -0800 (Fri, 09 Jan 2009)
New Revision: 9343
Modified:
branches/smask_work/base/gxdcolor.c
Log:
Change in gx_dc_write_color and gx_dc_read_color to write and read entire gx_color_index value instead of being dependent on the target device.
DETAILS: Having this dependency on the target device is really in conflict with how the transparency code should behave. Since the transparency blending occurs during the clist reading phase, the color value that is stored in the clist should be continuous tone in the color space defined by the transparency group, not dependent upon the bit depth and color space of the target device. These functions will need to be revisited to see what optimizations can be made (e.g. zero byte removal). They also need to be tested for the case when there are a large number of spot colors.
Modified: branches/smask_work/base/gxdcolor.c
===================================================================
--- branches/smask_work/base/gxdcolor.c 2009-01-10 05:33:50 UTC (rev 9342)
+++ branches/smask_work/base/gxdcolor.c 2009-01-10 06:01:49 UTC (rev 9343)
@@ -717,11 +717,14 @@
uint * psize )
{
int depth = dev->color_info.depth;
- int num_bytes = (depth + 8) >> 3; /* NB: +8, not +7 */
+ int num_bytes; /* NB: +8, not +7 */
/* gx_no_color_index is encoded as a single byte */
- if (color == gx_no_color_index)
+ if (color == gx_no_color_index) {
num_bytes = 1;
+ } else {
+ num_bytes = sizeof(gx_color_index) + 1;
+ }
/* check for adequate space */
if (*psize < num_bytes) {
@@ -735,8 +738,6 @@
*psize = 1;
*pdata = 0xff;
} else {
- if (depth < 8 * arch_sizeof_color_index)
- color &= ((gx_color_index)1 << depth) - 1;
while (--num_bytes >= 0) {
pdata[num_bytes] = color & 0xff;
color >>= 8;
@@ -763,6 +764,7 @@
*
* Returns: # of bytes read, or < 0 in the event of an error
*/
+
int
gx_dc_read_color(
gx_color_index * pcolor,
@@ -771,21 +773,22 @@
int size )
{
gx_color_index color = 0;
- int depth = dev->color_info.depth;
- int i, num_bytes = (depth + 8) >> 3; /* NB: +8, not +7 */
+ int i, num_bytes;
/* check that enough data has been provided */
- if (size < 1 || (pdata[0] != 0xff && size < num_bytes))
+ if (size < 1 || (pdata[0] != 0xff && size < sizeof(gx_color_index)))
return_error(gs_error_rangecheck);
/* check of gx_no_color_index */
if (pdata[0] == 0xff) {
*pcolor = gx_no_color_index;
return 1;
+ } else {
+ num_bytes = sizeof(gx_color_index) + 1;
}
/* num_bytes > arch_sizeof_color_index, discard first byte */
- for (i = (num_bytes >= arch_sizeof_color_index ? 1 : 0); i < num_bytes; i++)
+ for (i = 0; i < num_bytes; i++)
color = (color << 8) | pdata[i];
*pcolor = color;
return num_bytes;
More information about the gs-cvs
mailing list