postp9bit.ps 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. %
  2. % Version 3.3 prologue for plan9 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. /bitspersample exch def
  48. %% /v8format exch def
  49. /bytelength scanlength bitspersample mult 7 add 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. getp9bitmap
  62. grestore
  63. } bind def
  64. /getp9bitmap {
  65. scanlength scanlines bitspersample [scanlength 0 0 scanlines neg 0 scanlines] {
  66. currentfile picstr readhexstring pop} image
  67. } bind def
  68. /done {/lastpage where {pop lastpage} if} def