postdmd.ps 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. %
  2. % Version 3.3.2 prologue for DMD bitmap files.
  3. %
  4. /#copies 1 store
  5. /aspectratio 1 def
  6. /formsperpage 1 def
  7. /landscape false def
  8. /magnification 1 def
  9. /margin 0 def
  10. /orientation 0 def
  11. /rotation 1 def
  12. /screenres 100 def
  13. /xoffset 0 def
  14. /yoffset 0 def
  15. /useclippath true def
  16. /pagebbox [0 0 612 792] def
  17. /inch {72 mul} bind def
  18. /min {2 copy gt {exch} if pop} bind def
  19. /setup {
  20. counttomark 2 idiv {def} repeat pop
  21. landscape {/orientation 90 orientation add def} if
  22. pagedimensions
  23. xcenter ycenter translate
  24. orientation rotation mul rotate
  25. xoffset inch yoffset inch translate
  26. magnification dup aspectratio mul scale
  27. /height height margin sub def
  28. /width width margin sub def
  29. } def
  30. /pagedimensions {
  31. useclippath {
  32. /pagebbox [clippath pathbbox newpath] def
  33. } if
  34. pagebbox aload pop
  35. 4 -1 roll exch 4 1 roll 4 copy
  36. landscape {4 2 roll} if
  37. sub /width exch def
  38. sub /height exch def
  39. add 2 div /xcenter exch def
  40. add 2 div /ycenter exch def
  41. userdict /gotpagebbox true put
  42. } def
  43. /pagesetup {/page exch def} bind def
  44. /bitmap {
  45. /scanlines exch def
  46. /scanlength exch def
  47. /flip exch def
  48. /v8format exch def
  49. /bytelength scanlength 8 idiv def
  50. /picstr bytelength string def
  51. /lpicstr bytelength string def
  52. /bytelength bytelength 1 sub def
  53. gsave
  54. % First the overall scaling.
  55. height scanlines div width scanlength div min
  56. 72 screenres div min
  57. dup scale
  58. % Followed by the one for the unit square.
  59. scanlength neg 2 div scanlines neg 2 div translate
  60. scanlength scanlines scale
  61. v8format {getv8bitmap} {getbitmap} ifelse
  62. grestore
  63. } bind def
  64. /getbitmap {
  65. scanlength scanlines flip [scanlength 0 0 scanlines neg 0 scanlines] {
  66. 0 {
  67. currentfile token pop dup
  68. 0 eq {pop pop exit} if
  69. /charcount exch def
  70. picstr 1 index charcount getinterval
  71. /repl exch def
  72. currentfile repl readhexstring pop pop
  73. charcount add
  74. currentfile token pop {
  75. picstr 1 index repl putinterval
  76. charcount add
  77. } repeat
  78. } loop
  79. picstr
  80. } imagemask
  81. } bind def
  82. /getv8bitmap {
  83. scanlength scanlines flip not [scanlength 0 0 scanlines neg 0 scanlines] {
  84. 0 {
  85. currentfile token pop dup
  86. 0 eq {pop pop exit} if
  87. /charcount exch def
  88. picstr 1 index charcount getinterval
  89. /repl exch def
  90. currentfile repl readhexstring pop pop
  91. charcount add
  92. currentfile token pop {
  93. picstr 1 index repl putinterval
  94. charcount add
  95. } repeat
  96. } loop
  97. 0 0 picstr {
  98. exch lpicstr exch get xor
  99. lpicstr exch 2 index exch put
  100. 1 add dup
  101. } forall
  102. pop pop lpicstr
  103. } imagemask
  104. } bind def
  105. /done {/lastpage where {pop lastpage} if} def