summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2011-07-29 14:01:58 -0700
committerChris Liddell <chris.liddell@artifex.com>2011-07-30 09:21:54 +0100
commit83c7aba31ab324d015a39ec23ab9eb861c23d787 (patch)
treeb8d59cdd6ee5ef83df6c929893dbd6a89240c470
parentdb4b6b6d07c2b4a97bd0add6e3169874ec2d1af7 (diff)
downloadghostpdl-83c7aba31ab324d015a39ec23ab9eb861c23d787.tar.gz
Another fix for cups RGBW. This gets the color set up properly for RGB.
-rw-r--r--gs/base/gsicc_manage.c5
-rw-r--r--gs/base/gsicc_manage.h2
-rw-r--r--gs/cups/gdevcups.c54
3 files changed, 39 insertions, 22 deletions
diff --git a/gs/base/gsicc_manage.c b/gs/base/gsicc_manage.c
index 7f20e4a1d..a2b231969 100644
--- a/gs/base/gsicc_manage.c
+++ b/gs/base/gsicc_manage.c
@@ -59,9 +59,6 @@ static void rc_free_icc_profile(gs_memory_t * mem, void *ptr_in,
client_name_t cname);
static int gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s,
gs_memory_t *memory);
-static int gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem,
- char *file_name,
- gsicc_profile_types_t defaulttype);
static stream* gsicc_open_search(const char* pname, int namelen,
gs_memory_t *mem_gc,
const char* dirname, int dir_namelen);
@@ -1053,7 +1050,7 @@ gsicc_init_device_profile_struct(gx_device * dev,
in the icc_struct member variable of the device. This should
really occur only one time, but may occur twice if a color model is
specified or a nondefault profile is specified on the command line */
-static int
+int
gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem, char *file_name,
gsicc_profile_types_t pro_enum)
{
diff --git a/gs/base/gsicc_manage.h b/gs/base/gsicc_manage.h
index 52656db9b..f9744ae00 100644
--- a/gs/base/gsicc_manage.h
+++ b/gs/base/gsicc_manage.h
@@ -115,6 +115,8 @@ bool gs_currentoverride_ri(const gs_imager_state *pis);
cmm_profile_t* gsicc_set_iccsmaskprofile(const char *pname, int namelen,
gsicc_manager_t *icc_manager,
gs_memory_t *mem);
+int gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem,
+ char *file_name, gsicc_profile_types_t defaulttype);
#if ICC_DUMP
static void dump_icc_buffer(int buffersize, char filename[],byte *Buffer);
diff --git a/gs/cups/gdevcups.c b/gs/cups/gdevcups.c
index 838f183e6..c45b85380 100644
--- a/gs/cups/gdevcups.c
+++ b/gs/cups/gdevcups.c
@@ -69,6 +69,7 @@
#include "gdevprn.h"
#include "gsparam.h"
#include "arch.h"
+#include "gsicc_manage.h"
#include <stdlib.h>
#include <ctype.h>
@@ -625,14 +626,13 @@ cups_get_color_comp_index(gx_device * pdev, const char * pname,
compare_color_names(pname, name_size, "Transparency"))
return 3;
case CUPS_CSPACE_RGBW :
- /* This behaves like CMYK */
- if (compare_color_names(pname, name_size, "Cyan"))
+ if (compare_color_names(pname, name_size, "Red"))
return 0;
- if (compare_color_names(pname, name_size, "Magenta"))
+ if (compare_color_names(pname, name_size, "Green"))
return 1;
- if (compare_color_names(pname, name_size, "Yellow"))
- return 2;
- if (compare_color_names(pname, name_size, "Black"))
+ if (compare_color_names(pname, name_size, "Blue"))
+ return 2;
+ if (compare_color_names(pname, name_size, "White"))
return 3;
else
return -1;
@@ -644,8 +644,6 @@ cups_get_color_comp_index(gx_device * pdev, const char * pname,
return 1;
if (compare_color_names(pname, name_size, "Blue"))
return 2;
- else
- return -1;
break;
case CUPS_CSPACE_CMYK :
# ifdef CUPS_RASTER_HAVE_COLORIMETRIC
@@ -2037,23 +2035,29 @@ cups_map_color_rgb(gx_device *pdev,/* I - Device info */
*/
k = cups->DecodeLUT[c3];
- c = cups->DecodeLUT[c0] + k;
- m = cups->DecodeLUT[c1] + k;
- y = cups->DecodeLUT[c2] + k;
+ c = cups->DecodeLUT[c0] + k - gx_max_color_value;
+ m = cups->DecodeLUT[c1] + k - gx_max_color_value;
+ y = cups->DecodeLUT[c2] + k - gx_max_color_value;
if (c > gx_max_color_value)
prgb[0] = gx_max_color_value;
- else
+ else if (c < 0)
+ prgb[0] = 0;
+ else
prgb[0] = c;
if (m > gx_max_color_value)
prgb[1] = gx_max_color_value;
+ else if (m < 0)
+ prgb[1] = 0;
else
prgb[1] = m;
if (y > gx_max_color_value)
prgb[2] = gx_max_color_value;
- else
+ else if (y < 0)
+ prgb[2] = 0;
+ else
prgb[2] = y;
break;
@@ -3618,7 +3622,6 @@ cups_put_params(gx_device *pdev, /* I - Device info */
return (0);
}
-
/*
* 'cups_set_color_info()' - Set the color information structure based on
* the required output.
@@ -3633,7 +3636,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
float m[3][3]; /* Color correction matrix */
char resolution[41]; /* Resolution string */
ppd_profile_t *profile; /* Color profile information */
-
+ int code;
#ifdef DEBUG
dprintf1("DEBUG2: cups_set_color_info(%p)\n", pdev);
@@ -3714,7 +3717,6 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
cups->color_info.depth = 4 * cups->header.cupsBitsPerColor;
cups->color_info.num_components = 4;
- cups->color_info.num_components = 4;
break;
#ifdef CUPS_RASTER_HAVE_COLORIMETRIC
@@ -3790,6 +3792,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
switch (cups->header.cupsColorSpace)
{
default :
+ case CUPS_CSPACE_RGBW :
case CUPS_CSPACE_W :
case CUPS_CSPACE_WHITE :
case CUPS_CSPACE_RGB :
@@ -3816,7 +3819,6 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
cups->color_info.polarity = GX_CINFO_POLARITY_ADDITIVE;
break;
- case CUPS_CSPACE_RGBW :
case CUPS_CSPACE_K :
case CUPS_CSPACE_GOLD :
case CUPS_CSPACE_SILVER :
@@ -4035,9 +4037,25 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
for (k = 0; k <= CUPS_MAX_VALUE; k ++)
cups->Density[k] = k;
}
+ /* Set up the ICC profile for ghostscript to use based upon the color space.
+ This is different than the PPD profile above which appears to be some sort
+ of matrix based TRC profile */
+ switch (cups->header.cupsColorSpace) {
+ /* Use RGB profile for this */
+ case CUPS_CSPACE_RGBW:
+ if (pdev->icc_struct == NULL) {
+ pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+ }
+ if (pdev->icc_struct->device_profile[gsDEFAULTPROFILE] == NULL) {
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ DEFAULT_RGB_ICC, gsDEFAULTPROFILE);
+ }
+ break;
+ default:
+ break;
+ }
}
-
/*
* 'cups_sync_output()' - Keep the user informed of our status...
*/