tpostdmd.ps - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tpostdmd.ps (2562B)
       ---
            1 %
            2 % Version 3.3.2 prologue for DMD bitmap files.
            3 %
            4 
            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
           16 
           17 /useclippath true def
           18 /pagebbox [0 0 612 792] def
           19 
           20 /inch {72 mul} bind def
           21 /min {2 copy gt {exch} if pop} bind def
           22 
           23 /setup {
           24         counttomark 2 idiv {def} repeat pop
           25 
           26         landscape {/orientation 90 orientation add def} if
           27 
           28         pagedimensions
           29         xcenter ycenter translate
           30         orientation rotation mul rotate
           31         xoffset inch yoffset inch translate
           32         magnification dup aspectratio mul scale
           33 
           34         /height height margin sub def
           35         /width width margin sub def
           36 } def
           37 
           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
           51 
           52 /pagesetup {/page exch def} bind def
           53 
           54 /bitmap {
           55         /scanlines exch def
           56         /scanlength exch def
           57         /flip exch def
           58         /v8format exch def
           59 
           60         /bytelength scanlength 8 idiv def
           61         /picstr bytelength string def
           62         /lpicstr bytelength string def
           63         /bytelength bytelength 1 sub def
           64 
           65         gsave
           66 
           67 % First the overall scaling.
           68 
           69         height scanlines div width scanlength div min
           70         72 screenres div min
           71         dup scale
           72 
           73 % Followed by the one for the unit square.
           74 
           75         scanlength neg 2 div scanlines neg 2 div translate
           76         scanlength scanlines scale
           77         v8format {getv8bitmap} {getbitmap} ifelse
           78         grestore
           79 } bind def
           80 
           81 /getbitmap {
           82         scanlength scanlines flip [scanlength 0 0 scanlines neg 0 scanlines] {
           83                 0 {
           84                         currentfile token pop dup
           85                         0 eq {pop pop exit} if
           86                         /charcount exch def
           87                         picstr 1 index charcount getinterval
           88                         /repl exch def
           89                         currentfile repl readhexstring pop pop
           90                         charcount add
           91                         currentfile token pop {
           92                                 picstr 1 index repl putinterval
           93                                 charcount add
           94                         } repeat
           95                 } loop
           96                 picstr
           97         } imagemask
           98 } bind def
           99 
          100 /getv8bitmap {
          101         scanlength scanlines flip not [scanlength 0 0 scanlines neg 0 scanlines] {
          102                 0 {
          103                         currentfile token pop dup
          104                         0 eq {pop pop exit} if
          105                         /charcount exch def
          106                         picstr 1 index charcount getinterval
          107                         /repl exch def
          108                         currentfile repl readhexstring pop pop
          109                         charcount add
          110                         currentfile token pop {
          111                                 picstr 1 index repl putinterval
          112                                 charcount add
          113                         } repeat
          114                 } loop
          115                 0 0 picstr {
          116                         exch lpicstr exch get xor
          117                         lpicstr exch 2 index exch put
          118                         1 add dup
          119                 } forall
          120                 pop pop lpicstr
          121         } imagemask
          122 } bind def
          123 
          124 /done {/lastpage where {pop lastpage} if} def