1 % Copyright (C) 2001, 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_devn.ps,v 1.3 2002/11/13 20:23:10 alexcher Exp $
17 % DeviceN color space method dictionary; this depends on gs_sepr.ps
20 % verify that DeviceN and Separation color spaces are supported
21 /.setdevicenspace where
24 /.setseparationspace where
31 { currentfile closefile }
34 .currentglobal true .setglobal
39 % <c1> ... <cm> <array> apply_devn_tint_xform <c1>' ... <cn>' <array>
41 % Apply the tint transformation for the DeviceN color intensity values.
42 /apply_devn_tint_xform
44 dup 1 get length 1 add exch
45 mark 2 index 2 add 2 roll
47 counttomark 2 add -2 roll pop
56 /cs_potential_indexed_base true
57 /cs_potential_pattern_base true
58 /cs_potential_alternate false
59 /cs_potential_icc_alternate false
60 /cs_get_ncomps { 1 get length } bind
61 /cs_get_range { 1 get length [ exch { 0 1 } repeat ] } bind
62 /cs_get_default_color { 1 get length { 1 } repeat } bind
65 { //apply_devn_tint_xform exec 2 get //.cs_get_currentgray exec }
68 { //apply_devn_tint_xform exec 2 get //.cs_get_currentrgb exec }
71 { //apply_devn_tint_xform exec 2 get //.cs_get_currentcmyk exec }
74 % a lot of validation is done by the cs_validate method
78 dup 1 get //check_array exec
80 type dup /nametype ne exch /stringtype ne and
85 dup 2 get //.cs_validate exec //.cs_potential_alternate exec not
86 //setcspace_rangecheck
88 dup 3 get //check_array exec xcheck not
94 % substitute the base space if appropriate
97 dup 2 get //.cs_substitute exec 2 copy eq
100 % retain only the new alternate space
103 % build all new structures in local VM
104 .currentglobal 3 1 roll //false .setglobal
106 % construct a new array and insert the new base color space
107 1 index dup length array copy dup 2 4 -1 roll put
117 % The Ghostscript interpreter works better when tinttransform procedures
118 % are translated into functions. Attempt to do that here.
120 /cs_prepare //converttinttransform
123 % Install the current color space.
125 % The current Ghostscript color space implementation requires that
126 % color spaces that provide a base or alternative color space set
127 % that base/alternative color space to be the current color space
128 % before attempting to set the original color space.
130 % Beginning with Acrobat 5, PDF apparently supports 1-component
131 % DeviceN color spaces with the single component "All" (the "PDF
132 % Reference", 3rd ed., p. 206 still describes this as illegal).
133 % We translate such calls to Separation color spaces.
137 % save the current color space
140 % set the base color space as the current color space
141 1 index 2 get //forcesetcolorspace
143 % set the indexed color space; restore the earlier space on error
145 dup 1 get dup length 1 eq exch 0 get /All eq and
147 dup length array copy
148 dup 0 /Separation put
150 { .setseparationspace }
152 { { .setdevicenspace } }
155 { cleartomark setcolorspace stop }
161 /cs_prepare_color { dup 1 get length //check_num_stack exec pop } bind
164 % If a DeviceN color space is not supported in native mode by
165 % the current process color model, Adobe implementations will always
166 % execute the tint transform procedure when setcolor is invoked.
167 % Ghostscript may have turned this transform into a sampled function,
168 % and even if this is not the case, will have sampled the transform
169 % when the color space is first set. Some applications depend on
170 % the Adobe behavior, so we implement it via the cs_complete_setcolor
173 /cs_complete_setcolor
178 currentcolorspace 3 get exec
179 currentcolorspace 2 get
180 //clear_setcolor_operands exec