pic: use troff drawing commands for filling objects
[troff.git] / home / ps / postp9bit.ps
blobee646331c74fa9b75fd00a962dc3978c62b6b191
2 % Version 3.3 prologue for plan9 bitmap files.
5 /#copies 1 store
6 /aspectratio 1 def
7 /formsperpage 1 def
8 /landscape false def
9 /magnification 1 def
10 /margin 0 def
11 /orientation 0 def
12 /rotation 1 def
13 /screenres 100 def
14 /xoffset 0 def
15 /yoffset 0 def
17 /useclippath true def
18 /pagebbox [0 0 612 792] def
20 /inch {72 mul} bind def
21 /min {2 copy gt {exch} if pop} bind def
23 /setup {
24         counttomark 2 idiv {def} repeat pop
26         landscape {/orientation 90 orientation add def} if
28         pagedimensions
29         xcenter ycenter translate
30         orientation rotation mul rotate
31         xoffset inch yoffset inch translate
32         magnification dup aspectratio mul scale
34         /height height margin sub def
35         /width width margin sub def
36 } def
38 /pagedimensions {
39         useclippath {
40                 /pagebbox [clippath pathbbox newpath] def
41         } if
42         pagebbox aload pop
43         4 -1 roll exch 4 1 roll 4 copy
44         landscape {4 2 roll} if
45         sub /width exch def
46         sub /height exch def
47         add 2 div /xcenter exch def
48         add 2 div /ycenter exch def
49         userdict /gotpagebbox true put
50 } def
52 /pagesetup {/page exch def} bind def
54 /bitmap {
55         /scanlines exch def
56         /scanlength exch def
57         /bitspersample exch def
58 %%      /v8format exch def
60         /bytelength scanlength bitspersample mult 7 add 8 idiv def
61         /picstr bytelength string def
62         /lpicstr bytelength string def
63 %%      /bytelength bytelength 1 sub def
65         gsave
67 % First the overall scaling.
69         height scanlines div width scanlength div min
70         72 screenres div min
71         dup scale
73 % Followed by the one for the unit square.
75         scanlength neg 2 div scanlines neg 2 div translate
76         scanlength scanlines scale
77         getp9bitmap
78         grestore
79 } bind def
81 /getp9bitmap {
82         scanlength scanlines bitspersample [scanlength 0 0 scanlines neg 0 scanlines] {
83                         currentfile picstr readhexstring pop} image
84 } bind def
86 /done {/lastpage where {pop lastpage} if} def