| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/image.ps,v 1.1 2005/12/18 07:21:38 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
/image-create { % => Mask Image Init SY SX
|
|
|
4 |
<< >>
|
|
|
5 |
dup /SX 3 index put
|
|
|
6 |
dup /SY 4 index put
|
|
|
7 |
dup /Init 5 index put
|
|
|
8 |
dup /Image 6 index put
|
|
|
9 |
dup /Mask 7 index put
|
|
|
10 |
|
|
|
11 |
exch pop
|
|
|
12 |
exch pop
|
|
|
13 |
exch pop
|
|
|
14 |
exch pop
|
|
|
15 |
exch pop
|
|
|
16 |
} def
|
|
|
17 |
|
|
|
18 |
/image-show { % => W H Image
|
|
|
19 |
% Check if image is transparent
|
|
|
20 |
dup /Mask get /null eq { % => W H Image
|
|
|
21 |
2 index
|
|
|
22 |
2 index % => W H Image W H
|
|
|
23 |
2 index /SX get
|
|
|
24 |
3 index /SY get
|
|
|
25 |
4 index /Image get
|
|
|
26 |
5 index /Init get % => W H Image W H SX SY Image Init
|
|
|
27 |
show-image % => W H Image
|
|
|
28 |
} {
|
|
|
29 |
2 index
|
|
|
30 |
2 index % => W H Image W H
|
|
|
31 |
2 index /SX get
|
|
|
32 |
3 index /SY get
|
|
|
33 |
4 index /Mask get
|
|
|
34 |
5 index /Image get
|
|
|
35 |
6 index /Init get % => W H Image W H SX SY Mask Image Init
|
|
|
36 |
show-transparent-image
|
|
|
37 |
} ifelse % => W H Image
|
|
|
38 |
pop pop pop
|
|
|
39 |
} def
|
|
|
40 |
|
|
|
41 |
/image-show-simple { % => Scale Y X Image
|
|
|
42 |
1 index
|
|
|
43 |
3 index moveto % => Scale Y X Image
|
|
|
44 |
|
|
|
45 |
dup /SX get 4 index mul
|
|
|
46 |
1 index /SY get 5 index mul % => Scale Y X Image W H
|
|
|
47 |
2 index image-show % => Scale Y X Image
|
|
|
48 |
|
|
|
49 |
pop pop pop pop
|
|
|
50 |
} def
|
|
|
51 |
|
|
|
52 |
/image-show-repeat-x { % => Scale YOffset XOffset Right Width Y X Image
|
|
|
53 |
dup /SX get 8 index mul
|
|
|
54 |
1 index /SY get 9 index mul % => Scale YOffset XOffset Right width Y X Image W H
|
|
|
55 |
|
|
|
56 |
% Fill part to the right
|
|
|
57 |
|
|
|
58 |
3 index % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
59 |
{ % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
60 |
dup
|
|
|
61 |
8 index ge { exit } if
|
|
|
62 |
|
|
|
63 |
dup 6 index moveto % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
64 |
|
|
|
65 |
2 index 2 index 5 index
|
|
|
66 |
image-show % => Scale YOffset XOffset Right width Y X Image W H CY
|
|
|
67 |
6 index add % => Scale YOffset XOffset Right width Y X Image W H CY
|
|
|
68 |
} loop
|
|
|
69 |
pop
|
|
|
70 |
% Fill part to the left
|
|
|
71 |
|
|
|
72 |
3 index
|
|
|
73 |
{ % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
74 |
dup 7 index add
|
|
|
75 |
5 index 10 index sub
|
|
|
76 |
lt { exit } if
|
|
|
77 |
|
|
|
78 |
dup 7 index sub
|
|
|
79 |
6 index moveto % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
80 |
|
|
|
81 |
2 index 2 index 5 index
|
|
|
82 |
image-show % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
83 |
|
|
|
84 |
6 index sub % => Scale YOffset XOffset Right width Y X Image W H CX
|
|
|
85 |
} loop
|
|
|
86 |
pop
|
|
|
87 |
pop pop
|
|
|
88 |
|
|
|
89 |
pop pop pop
|
|
|
90 |
pop pop pop
|
|
|
91 |
pop pop
|
|
|
92 |
} def
|
|
|
93 |
|
|
|
94 |
/image-show-repeat-y { % => Scale YOffset XOffset Bottom height Y X Image
|
|
|
95 |
dup /SX get 8 index mul
|
|
|
96 |
1 index /SY get 9 index mul % => Scale YOffset XOffset Bottom height Y X Image W H
|
|
|
97 |
|
|
|
98 |
% Fill part to the bottom
|
|
|
99 |
|
|
|
100 |
4 index % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
101 |
{ % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
102 |
6 index 1 index add
|
|
|
103 |
8 index le { exit } if
|
|
|
104 |
|
|
|
105 |
4 index 1 index moveto % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
106 |
|
|
|
107 |
2 index 2 index 5 index
|
|
|
108 |
image-show % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
109 |
6 index sub % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
110 |
} loop
|
|
|
111 |
pop
|
|
|
112 |
|
|
|
113 |
% Fill part to the top
|
|
|
114 |
|
|
|
115 |
4 index
|
|
|
116 |
{ % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
117 |
6 index 1 index exch sub
|
|
|
118 |
10 index 7 index add
|
|
|
119 |
ge { exit } if
|
|
|
120 |
|
|
|
121 |
4 index 1 index moveto % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
122 |
|
|
|
123 |
2 index 2 index 5 index
|
|
|
124 |
image-show % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
125 |
|
|
|
126 |
6 index add % => Scale YOffset XOffset Bottom height Y X Image W H CY
|
|
|
127 |
} loop
|
|
|
128 |
pop
|
|
|
129 |
pop pop
|
|
|
130 |
|
|
|
131 |
pop pop pop
|
|
|
132 |
pop pop pop
|
|
|
133 |
pop pop
|
|
|
134 |
} def
|
|
|
135 |
|
|
|
136 |
/image-show-repeat-xy { % => Scale YOffset XOffset Bottom Right Height Width Y X Image
|
|
|
137 |
dup /SX get 10 index mul
|
|
|
138 |
1 index /SY get 11 index mul % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H
|
|
|
139 |
|
|
|
140 |
% Fill bottom-right quadrant
|
|
|
141 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
142 |
{
|
|
|
143 |
dup 8 index add
|
|
|
144 |
10 index le { exit } if % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
145 |
|
|
|
146 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
147 |
{
|
|
|
148 |
dup 10 index ge { exit } if
|
|
|
149 |
|
|
|
150 |
dup 2 index moveto
|
|
|
151 |
3 index 3 index 6 index
|
|
|
152 |
image-show
|
|
|
153 |
|
|
|
154 |
7 index add
|
|
|
155 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
156 |
pop
|
|
|
157 |
|
|
|
158 |
7 index sub
|
|
|
159 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
160 |
pop
|
|
|
161 |
|
|
|
162 |
% Fill bottom-left quadrant
|
|
|
163 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
164 |
{
|
|
|
165 |
dup 8 index add
|
|
|
166 |
10 index le { exit } if % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
167 |
|
|
|
168 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
169 |
{
|
|
|
170 |
dup 8 index add
|
|
|
171 |
6 index 13 index sub
|
|
|
172 |
le { exit } if
|
|
|
173 |
|
|
|
174 |
dup 2 index moveto
|
|
|
175 |
3 index 3 index 6 index
|
|
|
176 |
image-show
|
|
|
177 |
|
|
|
178 |
7 index sub
|
|
|
179 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
180 |
pop
|
|
|
181 |
|
|
|
182 |
7 index sub
|
|
|
183 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
184 |
pop
|
|
|
185 |
|
|
|
186 |
% Fill top-right quadrant
|
|
|
187 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
188 |
{
|
|
|
189 |
dup
|
|
|
190 |
6 index 13 index add
|
|
|
191 |
gt { exit } if % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
192 |
|
|
|
193 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
194 |
{
|
|
|
195 |
dup 10 index gt { exit } if
|
|
|
196 |
|
|
|
197 |
dup 2 index moveto
|
|
|
198 |
3 index 3 index 6 index
|
|
|
199 |
image-show
|
|
|
200 |
|
|
|
201 |
7 index add
|
|
|
202 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
203 |
pop
|
|
|
204 |
|
|
|
205 |
7 index add
|
|
|
206 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
207 |
pop
|
|
|
208 |
|
|
|
209 |
% Fill top-left quadrant
|
|
|
210 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
211 |
{
|
|
|
212 |
dup
|
|
|
213 |
6 index 13 index add
|
|
|
214 |
ge { exit } if % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
215 |
|
|
|
216 |
4 index % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
217 |
{
|
|
|
218 |
dup 8 index add
|
|
|
219 |
6 index 13 index sub
|
|
|
220 |
le { exit } if
|
|
|
221 |
|
|
|
222 |
dup 2 index moveto
|
|
|
223 |
3 index 3 index 6 index
|
|
|
224 |
image-show
|
|
|
225 |
|
|
|
226 |
7 index sub
|
|
|
227 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY CX
|
|
|
228 |
pop
|
|
|
229 |
|
|
|
230 |
7 index add
|
|
|
231 |
} loop % => Scale YOffset XOffset Bottom Right Height Width Y X Image W H CY
|
|
|
232 |
pop
|
|
|
233 |
|
|
|
234 |
pop pop
|
|
|
235 |
|
|
|
236 |
pop pop pop
|
|
|
237 |
pop pop pop
|
|
|
238 |
pop pop pop
|
|
|
239 |
pop
|
|
|
240 |
} def
|
|
|
241 |
|
|
|
242 |
/show-image { % => W H W H Samples InitFunc
|
|
|
243 |
exec % => W H W H Samples
|
|
|
244 |
|
|
|
245 |
gsave
|
|
|
246 |
|
|
|
247 |
matrix % => W H W H Samples Matr
|
|
|
248 |
currentpoint % => W H W H Samples Matr X Y
|
|
|
249 |
translate % => W H W H Samples Matr'
|
|
|
250 |
5 index
|
|
|
251 |
4 index div % => W H W H Samples Matr' KX
|
|
|
252 |
5 index
|
|
|
253 |
4 index div neg % => W H W H Samples Matr' KX KY
|
|
|
254 |
scale % => W H W H Samples Matr''
|
|
|
255 |
|
|
|
256 |
translate % => W H W H Samples Matr
|
|
|
257 |
|
|
|
258 |
<<
|
|
|
259 |
/ImageType 1
|
|
|
260 |
/Width 7 index
|
|
|
261 |
/Height 8 index
|
|
|
262 |
/BitsPerComponent 8
|
|
|
263 |
/Decode [0 1 0 1 0 1]
|
|
|
264 |
/ImageMatrix 12 index
|
|
|
265 |
/DataSource 15 index
|
|
|
266 |
>>
|
|
|
267 |
|
|
|
268 |
image
|
|
|
269 |
|
|
|
270 |
grestore
|
|
|
271 |
|
|
|
272 |
pop pop pop
|
|
|
273 |
pop pop pop
|
|
|
274 |
} def
|
|
|
275 |
|
|
|
276 |
/show-transparent-image { % => W H W H Mask Samples InitFunc
|
|
|
277 |
exec % => W H W H Mask Samples
|
|
|
278 |
|
|
|
279 |
gsave
|
|
|
280 |
|
|
|
281 |
matrix % => W H W H Mask Samples Matr
|
|
|
282 |
currentpoint % => W H W H Mask Samples Matr X Y
|
|
|
283 |
translate % => W H W H Mask Samples Matr'
|
|
|
284 |
6 index
|
|
|
285 |
5 index div % => W H W H Mask Samples Matr' KX
|
|
|
286 |
6 index
|
|
|
287 |
5 index div neg % => W H W H Mask Samples Matr' KX KY
|
|
|
288 |
scale % => W H W H Mask Samples Matr''
|
|
|
289 |
|
|
|
290 |
translate % => W H W H Mask Samples Matr
|
|
|
291 |
|
|
|
292 |
% As support of type 3 images in ps2pdf is bad, we'll use this workaround
|
|
|
293 |
ps2pdf-transparency-hack {
|
|
|
294 |
<<
|
|
|
295 |
/ImageType no-transparency-output { 1 } { 4 } ifelse
|
|
|
296 |
/Width 8 index
|
|
|
297 |
/Height 9 index
|
|
|
298 |
/BitsPerComponent 8
|
|
|
299 |
/Decode [0 1 0 1 0 1]
|
|
|
300 |
/ImageMatrix 12 index
|
|
|
301 |
/DataSource 15 index
|
|
|
302 |
/MaskColor [0 0 0]
|
|
|
303 |
>>
|
|
|
304 |
} {
|
|
|
305 |
<<
|
|
|
306 |
/ImageType 3
|
|
|
307 |
/InterleaveType 3
|
|
|
308 |
/DataDict
|
|
|
309 |
<<
|
|
|
310 |
/ImageType 1
|
|
|
311 |
/Width 14 index
|
|
|
312 |
/Height 15 index
|
|
|
313 |
/BitsPerComponent 8
|
|
|
314 |
/Decode [0 1 0 1 0 1]
|
|
|
315 |
/ImageMatrix 18 index
|
|
|
316 |
/DataSource 21 index
|
|
|
317 |
>>
|
|
|
318 |
/MaskDict
|
|
|
319 |
<<
|
|
|
320 |
/ImageType 1
|
|
|
321 |
/Width 16 index
|
|
|
322 |
/Height 17 index
|
|
|
323 |
/BitsPerComponent 1
|
|
|
324 |
/Decode [0 1]
|
|
|
325 |
/ImageMatrix 20 index
|
|
|
326 |
/DataSource 24 index
|
|
|
327 |
>>
|
|
|
328 |
>>
|
|
|
329 |
} ifelse
|
|
|
330 |
|
|
|
331 |
image
|
|
|
332 |
|
|
|
333 |
grestore
|
|
|
334 |
|
|
|
335 |
pop pop pop pop
|
|
|
336 |
pop pop pop
|
|
|
337 |
} def
|
|
|
338 |
|