Debian Codegraph @

Resource/Init/gs_icc.ps

raw
1 % Copyright (C) 2001-2023 Artifex Software, Inc.
2 % All Rights Reserved.
3 %
4 % This software is provided AS-IS with no warranty, either express or
5 % implied.
6 %
7 % This software is distributed under license and may not be copied,
8 % modified or distributed except as expressly authorized under the terms
9 % of the license contained in the file LICENSE in this distribution.
10 %
11 % Refer to licensing information at http://www.artifex.com or contact
12 % Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
13 % CA 94129, USA, for further information.
14 %
15
16 % We need LanguageLevel 2 or higher in order to have setuserparams and
17 % << >> dictionaries
18 languagelevel dup 2 .max .setlanguagelevel
19
20 % ICCBased color space method dictionaries.
21 % This assumes gs_ciecs2.ps has already been processed.
22
23 .currentglobal //true .setglobal
24
25 % gs_res.ps uses these entries in colorspacedict
26 % to populate the ColorSpaceFamily resource, so we need
27 % to add the supported spaces.
28 %
29 systemdict /colorspacedict get begin
30 /ICCBased [] def
31 end
32
33 NOPSICC { (%END PSICC) .skipeof } if
34 % Now set up ICC profile loading for PostScript %%BeginICCProfile sections.
35
36 /cs-sig-dict <<
37 (XYZ ) 3
38 (Lab ) 3
39 (Luv ) 3
40 (YCbr) 3
41 (Yxy ) 3
42 (RGB ) 3
43 (GRAY) 1
44 (HSV ) 3
45 (HLS ) 3
46 (CMYK) 4
47 (CMY ) 3
48 >> readonly def
49
50 systemdict begin
51 /.ProcessICCcomment { % file comment -- file comment
52 dup
53 (%%BeginICCProfile) anchorsearch {
54 pop pop
55 DEBUG { (.ProcessICCcomment found %%BeginICCProfile) print flush } if
56
57 % load an ICC profile defined as comments (hex encoded).
58 % Ends with %%End at the start of a line. Read the data into
59 % an array of strings. This string can be used directly as a
60 % source for ReusableStreamDecode filter.
61 %
62 % stack: --file-- (%%BeginICCProfile: ...)
63 1 index 0 (%%EndICCProfile) /SubFileDecode filter
64 [ { counttomark 1 add index
65 64000 string readhexstring
66 not { exit } if
67 } loop
68 ] exch closefile
69
70 % make a seekable -file- out of the string array
71 mark /AsyncRead //true .dicttomark /ReusableStreamDecode filter
72 % stack: --file-- (%%BeginICCProfile: ...) --icc_subfile--
73
74 dup 16 setfileposition
75 dup (1234) readstring pop
76 1 index 0 setfileposition
77
78 //cs-sig-dict exch .knownget {
79 3 dict begin
80 /Alternate {0 /DeviceGray 0 /DeviceRGB /DeviceCMYK } 2 index get def
81 /N exch def
82 /DataSource exch def
83 [/ICCBased currentdict]
84 end
85 { setcolorspace } stopped {
86 pop
87 QUIET not { ( *** Unable to load ICC profile from PostScript DSC comments ***) = flush } if
88 } if
89 } {
90 pop
91 } ifelse
92 } {
93 pop % Not interested in this DSC comment
94 } ifelse
95 } .internalbind def
96
97 currentdict /cs-sig-dict undef
98
99 % Merge ProcessICCcomment with existing handler
100 /.ProcessICCcomment load /exec load
101 currentuserparams /ProcessDSCComment get
102 dup //null eq {pop {pop pop}} if /exec load
103 4 array astore cvx readonly
104 << /ProcessDSCComment 3 -1 roll >> setuserparams
105
106 currentdict /.ProcessICCcomment .undef
107
108 end % systemdict
109 %END PSICC
110 .setglobal
111 .setlanguagelevel