Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/lib/ghostscript/gs_sepr.ps – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | 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_sepr.ps,v 1.3 2003/04/26 18:40:16 dan Exp $
17
% Separation color space method dictionary
18
 
19
 
20
% verify that Separation color spaces are supported
21
/.setseparationspace where
22
  { pop }
23
  { currentfile closefile }
24
ifelse
25
 
26
.currentglobal true .setglobal
27
.cspace_util begin
28
 
29
 
30
%
31
%   <c1>  <array>   apply_sepr_tint_xform   <c1>' ... <cn>'  <array>
32
%
33
% Apply the tint transform for a Separation color space color intensity
34
% value.
35
%
36
/apply_sepr_tint_xform
37
  {
38
    exch //bound_0_1 exec
39
    mark exch 2 index 3 get exec
40
    counttomark 2 add -2 roll pop
41
  }
42
bind def
43
 
44
 
45
%
46
%  <cspace_array>   build_tintxform_function   <cspace_array>  <proc>
47
%
48
% Convert a tint transformation into a function, if possible. If this is
49
% successful, <proc> will be a function procedure (a two-element,
50
% execute-only, executable array whose first element is the function
51
% data structure and whose second element is the operator %execfunction.
52
% If it is not successful, <proc> will be the same as the tint transform
53
% in <cspace_array>.
54
%
55
% Note that, for PDF files, the tint transform will likely already be a
56
% function-array. In this case, <proc> will be this array, and thus will
57
% also be identical to the original tint transform.
58
%
59
% This procedure is used for both Separation and DeviceN color spaces.
60
%
61
/build_tintxform_function
62
  {
63
    dup 3 get dup .isencapfunction not
64
      {
65
        % Try a FunctionType 4 function first; build the function dictionary
66
        % in local VM.
67
        .currentglobal exch //false .setglobal
68
	% Make the dictionary a couple of elements large in case this fails
69
	% and we need the dictionary to build a sampled function.
70
        6 dict begin
71
        /FunctionType 4 def
72
        /Function exch def
73
        /Domain 2 index //.cs_get_range exec def
74
        /Range 2 index 2 get //.cs_get_range exec def
75
        currentdict end
76
        { .buildfunction }
77
        .internalstopped	% If .buildfunction fails then not type 4 func.
78
        {			% If not then try building a sampled (type 0) func.
79
	  % We are using the dictionary which was created before .buildfunction
80
          dup /Order 3 put
81
          dup /BitsPerSample 16 put
82
          { .buildsampledfunction }
83
          .internalstopped	% If .buildsamplefunction fails then invalid func.
84
          {			% Failed - Create a dummy tint transform function
85
	    % We are using the dictionary which was created before .buildfunction
86
    	    dup /Function {} put    % Replace invalid tint transform with dummy
87
    	    .buildfunction
88
    	  }
89
          if		% Check status from .buildsamplefunction/.internalstopped
90
	}
91
	if		% check status from .buildfunction/.intermalstopped
92
        % restore the VM mode
93
        exch .setglobal
94
      }
95
    if
96
  }
97
bind def
98
 
99
%
100
%  <array1>  <array2>   converttinttransform   <array1>  <array2'>
101
%
102
% Convert a Separation/DeviceN color space to use a function as a tint
103
% transformation, if this is possible. Possible outcomes are:
104
%
105
%  1. The tint transform already is a function, or is a procedure that
106
%     cannot be converted to a function. In either case, <array2> is
107
%     left unchanged (<array2> == <array2'>).
108
%
109
%  2. The tint transform is not already a function but can be converted
110
%     to a function, and <array1> != <array2>. In this case, <array2>
111
%     is modified directly.
112
%
113
%  3. The tint transform is not already a function but can be converted
114
%     to a function, and <array1> == <array2>. In this case, <array2>
115
%     is copied, and the copy is modified (i.e., after the operation
116
%     <array1> != <array2>
117
%
118
% This slightly complex approach avoids creating an extra color space
119
% array unnecessarily.
120
%
121
/converttinttransform
122
  {
123
    % convert the tint transform to a fucntion
124
    //build_tintxform_function exec
125
 
126
    % see if anything needs to be modified
127
    1 index 3 get 2 copy eq
128
      { pop pop }
129
      {
130
        pop
131
 
132
        % see if the color space must be copied
133
        3 copy pop eq
134
          {
135
            % copy the array into local VM
136
            .currentglobal //false .setglobal
137
            3 -1 roll dup length array copy 3 1 roll
138
            .setglobal
139
          }
140
        if
141
        1 index exch 3 exch put
142
      }
143
    ifelse
144
  }
145
bind def
146
 
147
 
148
colorspacedict
149
/Separation
150
  mark
151
    /cs_potential_indexed_base true
152
    /cs_potential_pattern_base true
153
    /cs_potential_alternate false
154
    /cs_potential_icc_alternate false
155
    /cs_get_ncomps //ncomps_1
156
    /cs_get_range //get_range_1
157
    /cs_get_default_color { pop 1 } bind
158
 
159
    /cs_get_currentgray
160
      { //apply_sepr_tint_xform exec 2 get //.cs_get_currentgray exec }
161
    bind
162
    /cs_get_currentrgb
163
      { //apply_sepr_tint_xform exec 2 get //.cs_get_currentrgb exec }
164
    bind
165
    /cs_get_currentcmyk
166
      { //apply_sepr_tint_xform exec 2 get //.cs_get_currentcmyk exec }
167
    bind
168
 
169
    % a lot of validation is done by the cs_validate method
170
    /cs_validate
171
      {
172
        //check_array exec
173
        dup 1 get type dup /nametype ne exch /stringtype ne and
174
          //setcspace_typecheck
175
        if
176
        dup 2 get //.cs_validate exec //.cs_potential_alternate exec not
177
          //setcspace_rangecheck
178
        if
179
        dup 3 get //check_array exec xcheck not
180
          //setcspace_typecheck
181
        if
182
      }
183
    bind
184
 
185
    % substitute the base space if appropriate
186
    /cs_substitute
187
      {
188
        dup 2 get //.cs_substitute exec 2 copy eq
189
          { pop pop dup }
190
          {
191
            % retain only the new alternate space
192
            exch pop
193
 
194
            % build all new structures in local VM
195
            .currentglobal 3 1 roll //false .setglobal
196
 
197
            % construct a new array and insert the new base color space
198
            1 index dup length array copy dup 2 4 -1 roll put
199
 
200
            % restore VM mode
201
            3 -1 roll .setglobal
202
          }
203
        ifelse
204
      }
205
    bind
206
 
207
    %
208
    % The Ghostscript interpreter works better when tinttransform procedures
209
    % are translated into functions. Attempt to do that here.
210
    %
211
    /cs_prepare //converttinttransform
212
 
213
    %
214
    % Install the current color space.
215
    %
216
    % The current Ghostscript color space implementation requires that
217
    % color spaces that provide a base or alternative color space set
218
    % that base/alternative color space to be the current color space
219
    % before attempting to set the original color space.
220
    %
221
    /cs_install
222
      {
223
        % save the current color space
224
        currentcolorspace
225
 
226
        % set the base color space as the current color space
227
        1 index 2 get //forcesetcolorspace
228
 
229
        % set the indexed color space; restore the earlier space on error
230
        mark 2 index
231
          { .setseparationspace }
232
        stopped
233
          { cleartomark setcolorspace stop }
234
          { pop pop pop }
235
        ifelse
236
      }
237
    bind
238
 
239
    /cs_prepare_color //validate_1
240
 
241
    %
242
    % If a Separation color space is not supported in native mode by
243
    % the current process color model, Adobe implementations will always
244
    % execute the tint transform procedure when setcolor is invoked.
245
    % Ghostscript may have turned this transform into a sampled function,
246
    % and even if this is not the case, will have sampled the transform
247
    % when the color space is first set. Some applications may depend
248
    % on the Adobe behavior, so we implement it via the
249
    % cs_complete_setcolor method.
250
    %
251
    /cs_complete_setcolor
252
      {
253
        .usealternate
254
          {
255
            currentcolor exch 3 get exec
256
            currentcolorspace 2 get //clear_setcolor_operands exec
257
          }
258
          { pop }
259
        ifelse
260
      }
261
    bind
262
 
263
  .dicttomark
264
put
265
 
266
end     % .cspace_util
267
.setglobal