Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 2001, 2002 Aladdin Enterprises.  All rights reserved.
2
% 
3
% This software is provided AS-IS with no warranty, either express or
4
% implied.
5
% 
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.
9
% 
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.
15
 
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
18
 
19
 
20
% verify that DeviceN and Separation color spaces are supported
21
/.setdevicenspace where
22
  {
23
    pop
24
    /.setseparationspace where
25
      { pop //false }
26
      { //true }
27
    ifelse
28
  }
29
  { //true }
30
ifelse
31
  { currentfile closefile }
32
if
33
 
34
.currentglobal true .setglobal
35
.cspace_util begin
36
 
37
 
38
%
39
%   <c1> ... <cm>  <array>   apply_devn_tint_xform   <c1>' ... <cn>'  <array>
40
%
41
% Apply the tint transformation for the DeviceN color intensity values.
42
/apply_devn_tint_xform
43
  {
44
    dup 1 get length 1 add exch
45
    mark 2 index 2 add 2 roll
46
    index 3 get exec
47
    counttomark 2 add -2 roll pop
48
  }
49
bind def
50
 
51
 
52
 
53
colorspacedict
54
/DeviceN
55
  mark
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
63
 
64
    /cs_get_currentgray
65
      { //apply_devn_tint_xform exec 2 get //.cs_get_currentgray exec }
66
    bind
67
    /cs_get_currentrgb
68
      { //apply_devn_tint_xform exec 2 get //.cs_get_currentrgb exec }
69
    bind
70
    /cs_get_currentcmyk
71
      { //apply_devn_tint_xform exec 2 get //.cs_get_currentcmyk exec }
72
    bind
73
 
74
    % a lot of validation is done by the cs_validate method
75
    /cs_validate
76
      {
77
        //check_array exec
78
        dup 1 get //check_array exec
79
          {
80
            type dup /nametype ne exch /stringtype ne and
81
              //setcspace_typecheck
82
            if
83
          }
84
        forall
85
        dup 2 get //.cs_validate exec //.cs_potential_alternate exec not
86
          //setcspace_rangecheck
87
        if
88
        dup 3 get //check_array exec xcheck not
89
          //setcspace_typecheck
90
        if
91
      }
92
    bind
93
 
94
    % substitute the base space if appropriate
95
    /cs_substitute
96
      {
97
        dup 2 get //.cs_substitute exec 2 copy eq
98
          { pop pop dup }
99
          {
100
            % retain only the new alternate space
101
            exch pop
102
 
103
            % build all new structures in local VM
104
            .currentglobal 3 1 roll //false .setglobal
105
 
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
108
 
109
            % restore VM mode
110
            3 -1 roll .setglobal
111
          }
112
        ifelse
113
      }
114
    bind
115
 
116
    %
117
    % The Ghostscript interpreter works better when tinttransform procedures
118
    % are translated into functions. Attempt to do that here.
119
    %
120
    /cs_prepare //converttinttransform
121
 
122
    %
123
    % Install the current color space.
124
    %
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.
129
    %
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.
134
    %
135
    /cs_install
136
      {
137
        % save the current color space
138
        currentcolorspace
139
 
140
        % set the base color space as the current color space
141
        1 index 2 get //forcesetcolorspace
142
 
143
        % set the indexed color space; restore the earlier space on error
144
        mark 2 index
145
        dup 1 get dup length 1 eq exch 0 get /All eq and
146
          {
147
            dup length array copy
148
            dup 0 /Separation put
149
            dup 1 /All put
150
              { .setseparationspace }
151
          }
152
          { { .setdevicenspace } }
153
        ifelse
154
        stopped
155
          { cleartomark setcolorspace stop }
156
          { pop pop pop }
157
        ifelse
158
      }
159
    bind
160
 
161
    /cs_prepare_color { dup 1 get length //check_num_stack exec pop } bind
162
 
163
    %
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
171
    % method.
172
    %
173
    /cs_complete_setcolor
174
      {
175
        .usealternate
176
          {
177
            pop currentcolor
178
            currentcolorspace 3 get exec
179
            currentcolorspace 2 get
180
            //clear_setcolor_operands exec
181
          }
182
          { pop }
183
        ifelse
184
      }
185
    bind
186
 
187
  .dicttomark
188
put
189
 
190
end     % .cspace_util
191
.setglobal