2 |
- |
1 |
% Copyright (C) 1997, 1998 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_dpnxt.ps,v 1.5 2002/08/22 07:12:28 henrys Exp $
|
|
|
17 |
% gs_dpnxt.ps
|
|
|
18 |
% NeXT Display PostScript extensions
|
|
|
19 |
|
|
|
20 |
% Define the operation values for compositing. These must match the values
|
|
|
21 |
% in gsdpnext.h, which also are the ones from the NeXT documentation.
|
|
|
22 |
% We put them in systemdict, which seems like as good a place as any.
|
|
|
23 |
mark
|
|
|
24 |
/Clear /Copy /Sover /Sin /Sout /Satop /Dover /Din /Dout /Datop /Xor
|
|
|
25 |
/PlusD /PlusL /Highlight % not sure about Highlight
|
|
|
26 |
counttomark { counttomark 1 sub def } repeat pop
|
|
|
27 |
|
|
|
28 |
% We implement readimage and sizeimage using the following 3 otherwise
|
|
|
29 |
% undocumented lower-level operators:
|
|
|
30 |
%
|
|
|
31 |
% <x> <y> <width> <height> <matrix> .sizeimagebox
|
|
|
32 |
% <dev_x> <dev_y> <dev_width> <dev_height> <matrix>
|
|
|
33 |
%
|
|
|
34 |
% - .sizeimageparams <bits/sample> <multiproc> <ncolors>
|
|
|
35 |
%
|
|
|
36 |
% <device> <x> <y> <width> <max_height> <alpha?> <std_depth|null>
|
|
|
37 |
% <string> .getbitsrect <height> <substring>
|
|
|
38 |
%
|
|
|
39 |
% NOTE: These operators are subject to change without notice!
|
|
|
40 |
|
|
|
41 |
% Implement readimage using .getbitsrect. Experimentation on a NeXT system
|
|
|
42 |
% shows that the data is always returned in order of increasing device Y,
|
|
|
43 |
% regardless of the CTM.
|
|
|
44 |
%
|
|
|
45 |
% Note that we can't make stack protection work for this operator,
|
|
|
46 |
% because it must remove its operands from the stack before calling
|
|
|
47 |
% the supplied procedure(s).
|
|
|
48 |
|
|
|
49 |
/readimage { % <x> <y> <width> <height> <proc> [... <procN-1>]
|
|
|
50 |
% <string> <alpha?> readimage -
|
|
|
51 |
.sizeimageparams exch {
|
|
|
52 |
% multiproc = true. If N > 1, store the procedures in an array.
|
|
|
53 |
exch pop 1 index { 1 add } if
|
|
|
54 |
% Stack: ... string alpha? nprocs
|
|
|
55 |
dup 1 eq {
|
|
|
56 |
pop false % only 1 procedure, multiproc is irrelevant
|
|
|
57 |
} {
|
|
|
58 |
dup array 4 1 roll 3 add 2 roll astore 3 1 roll true
|
|
|
59 |
} ifelse
|
|
|
60 |
} {
|
|
|
61 |
% multiproc = false.
|
|
|
62 |
pop pop false
|
|
|
63 |
} ifelse
|
|
|
64 |
% Map the rectangle to device coordinates.
|
|
|
65 |
% Stack: x y w h proc(s) str alpha? multi?
|
|
|
66 |
8 -4 roll matrix .sizeimagebox pop 8 4 roll
|
|
|
67 |
% Make sure we allocate the operand array in local VM
|
|
|
68 |
% to avoid a possible invalidaccess.
|
|
|
69 |
.currentglobal false .setglobal 9 1 roll
|
|
|
70 |
exch { 1 } { 0 } ifelse exch % alpha is last, if present
|
|
|
71 |
exch 4 1 roll 8 array astore exch .setglobal
|
|
|
72 |
{ % Read out a block of scan lines and pass them to the procedure.
|
|
|
73 |
% Stack: [x y w h alpha? proc(s) str multi?] -- we must consume this.
|
|
|
74 |
dup 3 get 0 eq { pop exit } if
|
|
|
75 |
aload 9 1 roll pop exch pop currentdevice 7 1 roll
|
|
|
76 |
% Always read out the data as standard (not native) pixels.
|
|
|
77 |
.sizeimageparams pop pop exch .getbitsrect
|
|
|
78 |
% Stack: [x y w h alpha? proc(s) str multi?] hread substr
|
|
|
79 |
3 -1 roll
|
|
|
80 |
% Stack: hread substr [x y w h alpha? proc(s) str multi?]
|
|
|
81 |
dup 1 2 copy get 5 index add put
|
|
|
82 |
% Stack: hread substr [x y' w h alpha? proc(s) str multi?]
|
|
|
83 |
dup 3 2 copy get 6 -1 roll sub put
|
|
|
84 |
% Stack: substr [x y' w h' alpha? proc(s) str multi?]
|
|
|
85 |
dup 5 get exch 7 get {
|
|
|
86 |
% multiproc = true, pass each plane to a different procedure.
|
|
|
87 |
% Stack: substr procs
|
|
|
88 |
|
|
|
89 |
% Push 1 plane and its procedure under the top 2 elements.
|
|
|
90 |
% Stack: ... substr procs plane#
|
|
|
91 |
2 index length 2 index length idiv % bytes per plane
|
|
|
92 |
dup 2 index mul exch
|
|
|
93 |
% Stack: ... substr procs plane# start length
|
|
|
94 |
4 index 3 1 roll getinterval 4 1 roll
|
|
|
95 |
2 copy get 4 1 roll pop
|
|
|
96 |
} for
|
|
|
97 |
exch pop length 2 mul .execn
|
|
|
98 |
} {
|
|
|
99 |
% multiproc = false, just call the procedure.
|
|
|
100 |
exec
|
|
|
101 |
} ifelse
|
|
|
102 |
} //systemdict /exec get 3 packedarray cvx loop
|
|
|
103 |
} bind odef
|
|
|
104 |
|
|
|
105 |
%
|
|
|
106 |
% <w> <h> <bpc> <mtx> <dsrc0> ... <multi> <ncomp> alphaimage -
|
|
|
107 |
%
|
|
|
108 |
img_utils_dict begin
|
|
|
109 |
/.alphaimage where
|
|
|
110 |
{
|
|
|
111 |
pop
|
|
|
112 |
currentglobal true setglobal
|
|
|
113 |
/alphaimage
|
|
|
114 |
{
|
|
|
115 |
//true
|
|
|
116 |
//.colorimage
|
|
|
117 |
stopped
|
|
|
118 |
{ /alphaimage load $error /errorname get signalerror }
|
|
|
119 |
if
|
|
|
120 |
}
|
|
|
121 |
.bind systemdict begin odef end
|
|
|
122 |
setglobal
|
|
|
123 |
}
|
|
|
124 |
if
|
|
|
125 |
end
|
|
|
126 |
|
|
|
127 |
% Implement sizeimage using lower-level operators.
|
|
|
128 |
|
|
|
129 |
/sizeimage { % <x> <y> <width> <height> <matrix> sizeimage
|
|
|
130 |
% <devwidth> <devheight> <bits/sample> <matrix>
|
|
|
131 |
% <multiproc> <ncolors>
|
|
|
132 |
.sizeimagebox 5 -2 roll pop pop
|
|
|
133 |
.sizeimageparams 3 -1 roll 4 1 roll
|
|
|
134 |
} bind odef
|