1 % Copyright (C) 2002 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: gs_devcs.ps,v 1.7 2005/09/12 11:34:50 leonardo Exp $
17 % Device-specific color space method dictionaries.
20 % This file implements the method dictionaries for the Device-specific
21 % color spaces. See gs_cspace.ps for information.
23 % Note that, because these color spaces are parameter-less, no color
24 % space validation is required: if we can get to the color space methods,
25 % we know the color space is legitimate.
27 % The colorspace substitution routines for these color spaces
28 % (cs_substitute) will fail in a Level 1 system, but this is not a
29 % problem as .getuseciecolor will always return false for such systems.
31 .currentglobal true .setglobal
35 % <r> <g> <b> rgb_2_gray <gray>
37 % Convert RGB colors to gray. This includes a special check for
38 % r == g == b, and avoids roundoff error if this is the case.
42 3 copy 1 index eq 3 1 roll eq and
44 { .11 mul exch .59 mul add exch .3 mul add }
49 systemdict /..page_default_spaces 3 dict put
51 % <color_space_name> ..includecolorspace -
53 { % Only includes ones explicitly defined by the document.
54 systemdict /..page_default_spaces get 1 index known {
58 { dup /ColorSpace resourcestatus {
60 systemdict /..page_default_spaces get 1 index //true put
62 { dup /ColorSpace findresource //_setcolorspace_nosub exec .includecolorspace
72 % <color_space> <color_space_name> cs_substitute_generic <color_space1> <color_space2>
73 /cs_substitute_generic
76 { //..includecolorspace exec dup }
77 { /ColorSpace findresource }
85 % <color_space> <color_space_name> cs_substitute_DeviceRGB_for_PDFX <color_space1> <color_space2>
86 /cs_substitute_DeviceRGB_for_PDFX
87 { systemdict /PDFX .knownget not { false } if {
88 dup /ColorSpace resourcestatus {
91 (Error: Need a /DefaultRGB /ColorSpace resource for generating a PDF/X document.) =
92 /cs_substitute_DeviceRGB_for_PDFX /undefined signalerror
94 /ColorSpace findresource
96 //cs_substitute_generic exec
105 /cs_potential_indexed_base true
106 /cs_potential_pattern_base true
107 /cs_potential_alternate true
108 /cs_potential_icc_alternate true
109 /cs_get_ncomps //ncomps_1
110 /cs_get_range //get_range_1
111 /cs_get_default_color { pop 0 } bind
112 /cs_get_currentgray //pop_1
113 /cs_get_currentrgb { pop dup dup } bind
114 /cs_get_currentcmyk { pop 1 exch sub 0 0 0 4 -1 roll } bind
118 { /DefaultGray //cs_substitute_generic exec
123 /cs_install { pop 0 .setdevcspace } bind
124 /cs_prepare_color //validate_1
125 /cs_complete_setcolor //pop_1
132 /cs_potential_indexed_base true
133 /cs_potential_pattern_base true
134 /cs_potential_alternate true
135 /cs_potential_icc_alternate true
136 /cs_get_ncomps //ncomps_3
137 /cs_get_range //get_range_3
138 /cs_get_default_color { pop 0 0 0 } bind
139 /cs_get_currentgray { pop //rgb_2_gray exec } bind
140 /cs_get_currentrgb //pop_1
142 % to convert to cmyk use blackgeneration and undercolorremoval
147 % convert to subtractive (CMY) color space
149 { 1 exch sub 3 1 roll }
152 % find the minimum (initial k component)
163 % apply undercolorremoval
164 dup 5 1 roll currentundercolorremoval exec 4 1 roll
166 { 3 index sub //bound_0_1 exec 3 1 roll }
169 % apply blackgeneration
170 5 3 roll pop currentblackgeneration exec //bound_0_1 exec
177 { /DefaultRGB //cs_substitute_DeviceRGB_for_PDFX exec
182 /cs_install { pop 1 .setdevcspace } bind
183 /cs_prepare_color //validate_3
184 /cs_complete_setcolor //pop_1
192 % Only create the DeviceCMYK color space if setcolorscreen is present
193 /setcolorscreen where
195 { currentfile closefile }
199 .currentglobal true .setglobal
205 /cs_potential_indexed_base true
206 /cs_potential_pattern_base true
207 /cs_potential_alternate true
208 /cs_potential_icc_alternate true
209 /cs_get_ncomps //ncomps_4
210 /cs_get_range //get_range_4
211 /cs_get_default_color { pop 0 0 0 1 } bind
214 { pop 4 1 roll //rgb_2_gray exec add 1 exch sub //bound_0_1 exec }
221 { 3 index add 1 exch sub //bound_0_1 exec 3 1 roll }
227 /cs_get_currentcmyk //pop_1
232 { /DefaultCMYK //cs_substitute_generic exec
237 /cs_install { pop 2 .setdevcspace } bind
238 /cs_prepare_color //validate_4
239 /cs_complete_setcolor //pop_1
243 currentdict /..includecolorspace .undef
244 currentdict /cs_substitute_generic .undef