summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2012-01-30 15:28:05 -0800
committerChris Liddell <chris.liddell@artifex.com>2012-01-31 18:11:41 +0000
commitdbf3d3403bc928c183b0674aa5adbb6263d56e42 (patch)
treee12c2d4c60f9e698e28c01261827483819fa1f5f
parent55049debcc22152c42a62b1fc350eb087125be5a (diff)
downloadghostpdl-dbf3d3403bc928c183b0674aa5adbb6263d56e42.tar.gz
Make device link profile work with lcms2. Also update documentation and add error handling.
The device link profile handling was put in place when we had lcms 1.8 but was not ported over to the 2.0 interface.
-rw-r--r--gs/base/gsicc.c6
-rw-r--r--gs/base/gsicc_lcms2.c55
-rw-r--r--gs/doc/Use.htm44
3 files changed, 79 insertions, 26 deletions
diff --git a/gs/base/gsicc.c b/gs/base/gsicc.c
index ab7c578b0..4d173c04d 100644
--- a/gs/base/gsicc.c
+++ b/gs/base/gsicc.c
@@ -338,6 +338,9 @@ gx_remap_ICC(const gs_client_color * pcc, const gs_color_space * pcs,
}
/* Get a link from the cache, or create if it is not there. Need to get 16 bit profile */
icc_link = gsicc_get_link(pis, dev, pcs, NULL, &rendering_params, pis->memory);
+ if (icc_link == NULL) {
+ return gs_rethrow(-1, "Could not create ICC link: Check profiles");
+ }
if (icc_link->is_identity) {
psrc_temp = &(psrc[0]);
} else {
@@ -410,6 +413,9 @@ gx_concretize_ICC(
}
/* Get a link from the cache, or create if it is not there. Get 16 bit profile */
icc_link = gsicc_get_link(pis, dev, pcs, NULL, &rendering_params, pis->memory);
+ if (icc_link == NULL) {
+ return gs_rethrow(-1, "Could not create ICC link: Check profiles");
+ }
/* Transform the color */
if (icc_link->is_identity) {
psrc_temp = &(psrc[0]);
diff --git a/gs/base/gsicc_lcms2.c b/gs/base/gsicc_lcms2.c
index 0fb8fff9b..347b39cc5 100644
--- a/gs/base/gsicc_lcms2.c
+++ b/gs/base/gsicc_lcms2.c
@@ -354,10 +354,8 @@ gscms_get_link(gcmmhprofile_t lcms_srchandle,
/* cmsFLAGS_HIGHRESPRECALC) cmsFLAGS_NOTPRECALC cmsFLAGS_LOWRESPRECALC*/
}
-/* Get the link from the CMS, but include proofing.
- We need to note that as an option in the rendering params. If we are doing
- transparency, that would only occur at the top of the stack
-TODO: Add error checking */
+/* Get the link from the CMS, but include proofing and/or a device link
+ profile. */
gcmmhlink_t
gscms_get_link_proof_devlink(gcmmhprofile_t lcms_srchandle,
gcmmhprofile_t lcms_proofhandle,
@@ -368,23 +366,46 @@ gscms_get_link_proof_devlink(gcmmhprofile_t lcms_srchandle,
cmsUInt32Number src_data_type,des_data_type;
cmsColorSpaceSignature src_color_space,des_color_space;
int src_nChannels,des_nChannels;
+ int lcms_src_color_space, lcms_des_color_space;
+ cmsHPROFILE hProfiles[5];
+ int nProfiles = 0;
- /* Get the data types */
+ /* First handle all the source stuff */
src_color_space = cmsGetColorSpace(lcms_srchandle);
- des_color_space = cmsGetColorSpace(lcms_deshandle);
+ lcms_src_color_space = _cmsLCMScolorSpace(src_color_space);
+ /* littlecms returns -1 for types it does not (but should) understand */
+ if (lcms_src_color_space < 0) lcms_src_color_space = 0;
src_nChannels = cmsChannelsOf(src_color_space);
+ /* For now, just do single byte data, interleaved. We can change this
+ when we use the transformation. */
+ src_data_type = (COLORSPACE_SH(lcms_src_color_space)|
+ CHANNELS_SH(src_nChannels)|BYTES_SH(2));
+ if (lcms_devlinkhandle == NULL) {
+ des_color_space = cmsGetColorSpace(lcms_deshandle);
+ } else {
+ des_color_space = cmsGetPCS(lcms_devlinkhandle);
+ }
+ lcms_des_color_space = _cmsLCMScolorSpace(des_color_space);
+ if (lcms_des_color_space < 0) lcms_des_color_space = 0;
des_nChannels = cmsChannelsOf(des_color_space);
- /* For now, just do single byte data, interleaved. We can change this when we
- use the transformation. */
- src_data_type= (CHANNELS_SH(src_nChannels)|BYTES_SH(1));
- des_data_type= (CHANNELS_SH(des_nChannels)|BYTES_SH(1));
- /* Create the link. Note the gamut check alarm */
- return(cmsCreateProofingTransform(lcms_srchandle, src_data_type,
- lcms_deshandle, des_data_type,
- lcms_proofhandle,
- rendering_params->rendering_intent,
- INTENT_ABSOLUTE_COLORIMETRIC,
- cmsFLAGS_GAMUTCHECK | cmsFLAGS_SOFTPROOFING ));
+ des_data_type = (COLORSPACE_SH(lcms_des_color_space)|
+ CHANNELS_SH(des_nChannels)|BYTES_SH(2));
+ /* lcms proofing transform has a clunky API and can't include the device
+ link profile if we have both. So use cmsCreateMultiprofileTransform
+ instead and round trip the proofing profile. */
+ hProfiles[nProfiles++] = lcms_srchandle;
+ if (lcms_proofhandle != NULL) {
+ hProfiles[nProfiles++] = lcms_proofhandle;
+ hProfiles[nProfiles++] = lcms_proofhandle;
+ }
+ hProfiles[nProfiles++] = lcms_deshandle;
+ if (lcms_devlinkhandle != NULL) {
+ hProfiles[nProfiles++] = lcms_devlinkhandle;
+ }
+ return(cmsCreateMultiprofileTransform(hProfiles, nProfiles, src_data_type,
+ des_data_type, rendering_params->rendering_intent,
+ (cmsFLAGS_BLACKPOINTCOMPENSATION |
+ cmsFLAGS_HIGHRESPRECALC)));
}
/* Do any initialization if needed to the CMS */
diff --git a/gs/doc/Use.htm b/gs/doc/Use.htm
index 632d73226..41b19fca8 100644
--- a/gs/doc/Use.htm
+++ b/gs/doc/Use.htm
@@ -2741,6 +2741,11 @@ Structuring Convention comments.
<h4><a name="ICC_color_parameters"></a>ICC color parameters</h4>
+<dd>
+For details about the ICC controls see the document
+<a href="GS9_Color_Management.pdf">GS9 Color Management</a>.
+</dd>
+
<dl>
<dt><code>-sDefaultGrayProfile=</code><em>filename</em>
<dd>Set the ICC profile that will be associated with
@@ -2779,17 +2784,26 @@ tool for creating these source profiles is contained in
<dl>
<dt><code>-sProofProfile=</code><em>filename</em>
-<dd>Define the proofing ICC profile. This is the profile for the
-device to which we would like the output to appear to be rendered.
-This is not fully implemented at this time.
+<dd>
+Enable the specificiation of a proofing profile that will make the
+color manegement system link multiple profiles together to emulate the
+device defined by the proofing profile. See the document
+<a href="GS9_Color_Management.pdf">GS9 Color Management</a> for details about this option.
</dl>
<dl>
<dt><code>-sDeviceLinkProfile=</code><em>filename</em>
-<dd>Define a device link profile through which the the rendered
-buffers should be remapped. This is not fully
-implemented at this time and will be only available for a select
-few devices.
+<dd>Define a device link profile. This profile is used following
+the output device profile. Care should be taken to ensure that the
+output device process color model is the same as the output color
+space for the device link profile. In addition, the color space of
+the OutputICCProfile should match the input color space of the device
+link profile. For example, the following would be a valid specification
+-sDEVICE=tiff32nc -sOutputICCProfile=srgb.icc -sDeviceLinkProfile=linkRGBtoCMYK.icc.
+In this case, the output device's color model is CMYK (tiff32nc) and the colors
+are mapped through sRGB and through a devicelink profile that maps sRGB to
+CMYK values. See the document
+<a href="GS9_Color_Management.pdf">GS9 Color Management</a> for details about this option.
</dl>
<dl>
@@ -2824,7 +2838,8 @@ device supports those colorants.
<dt><code>-sRenderIntent=</code><em>intent</em>
<dd>Set the rendering intent that should be used with the
profile specified above by -sOutputICCProfile. The
-options for <em>intent</em> are per, col , sat, and abs,
+options for <em>intent</em> are
+0, 1, 2, and 3,
which correspond to the ICC intents of Perceptual, Colorimetric,
Saturation, and Absolute Colorimetric.
Also see <a href="#OverrideRI">OverrideRI</a>.
@@ -2922,7 +2937,8 @@ number (0 for perceptual, 1 for colorimetric, 2 for saturation,
Profiles to demonstrate this method of specification are also
included in this folder. Note that if objects are colorimetrically
specified through this mechanism other operations like -sImageIntent,
--dOverrideICC, have no real affect.
+-dOverrideICC, have no real affect. See further details in the document
+<a href="GS9_Color_Management.pdf">GS9 Color Management</a>.
</dl>
<dl>
@@ -2937,6 +2953,16 @@ specify -dDeviceGrayToK=false.
</dl>
<dl>
+<dt><code>-dUseFastColor=</code><em>true/false</em>
+<dd>
+This is used to avoid the use of ICC profiles for source colors that
+are defined by DeviceGray, DeviceRGB and DeviceCMYK definitions. With
+UseFastColor set to true, the traditional Postscript 255 minus operations
+are used to convert between RGB and CMYK with black generation and undercolor
+removal mappings.
+</dl>
+
+<dl>
<dt><code>-sICCProfilesDir=</code><em>path</em>
<dd>Set a directory in which to search for the above profiles.
The directory path must end with a file system delimiter.