psdriver.ps 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. % ***************************************************************************
  2. %
  3. % MODULE: PS driver
  4. % AUTHOR(S): Glynn Clements <glynn@gclements.plus.com>
  5. % COPYRIGHT: (C) 2007 Glynn Clements
  6. %
  7. % This program is free software; you can redistribute it and/or modify
  8. % it under the terms of the GNU General Public License as published by
  9. % the Free Software Foundation; either version 2 of the License, or
  10. % (at your option) any later version.
  11. %
  12. % This program is distributed in the hope that it will be useful,
  13. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. % GNU General Public License for more details.
  16. %
  17. % ****************************************************************************
  18. /GRAY {
  19. 255.0 div
  20. setgray
  21. } bind def
  22. /COLOR {
  23. 3 2 roll 255 div
  24. 3 2 roll 255 div
  25. 3 2 roll 255 div
  26. setrgbcolor
  27. } bind def
  28. /BOX {
  29. newpath
  30. 3 index 3 index moveto
  31. 1 index 3 index lineto
  32. 1 index 1 index lineto
  33. 3 index 1 index lineto
  34. closepath fill
  35. pop pop pop pop
  36. } bind def
  37. /POINT {
  38. newpath
  39. moveto
  40. currentpoint lineto
  41. stroke
  42. } bind def
  43. /ERASE {
  44. erasepage
  45. } bind def
  46. /WIDTH {
  47. setlinewidth
  48. } bind def
  49. /BITMAP {
  50. gsave
  51. 4 2 roll translate
  52. 1 index 7 add 8 idiv string /tmpstr exch def
  53. true [1 0 0 1 0 0] {currentfile tmpstr readhexstring pop} imagemask
  54. grestore
  55. } bind def
  56. /RASTERGRAY {
  57. 8 exch
  58. 3 index string /tmpstr exch def
  59. {currentfile tmpstr readhexstring pop} image
  60. } bind def
  61. /RASTERRGB {
  62. 8 exch
  63. 3 index 3 mul string /tmpstr exch def
  64. {currentfile tmpstr readhexstring pop}
  65. false 3 colorimage
  66. } bind def
  67. /RASTERMASK {
  68. 6 dict begin
  69. /ncomp exch def
  70. /mat exch def
  71. /rows exch def
  72. /cols exch def
  73. /tmpstr ncomp 1 add cols mul string def
  74. /imgdict 4 dict def
  75. imgdict begin
  76. /ImageType 3 def
  77. /InterleaveType 1 def
  78. /MaskDict 6 dict def
  79. MaskDict begin
  80. /ImageType 1 def
  81. /Width cols def
  82. /Height rows def
  83. /ImageMatrix mat def
  84. /BitsPerComponent 8 def
  85. /Decode [0 1] def
  86. end
  87. /DataDict 7 dict def
  88. MaskDict DataDict copy pop
  89. DataDict begin
  90. /DataSource {currentfile tmpstr readhexstring pop} def
  91. /Decode [0 1 0 1 0 1] 0 ncomp 2 mul getinterval def
  92. end
  93. end
  94. imgdict image
  95. end
  96. } bind def
  97. /RASTERGRAYMASK {
  98. gsave
  99. /DeviceGray setcolorspace
  100. 1 RASTERMASK
  101. grestore
  102. } bind def
  103. /RASTERRGBMASK {
  104. gsave
  105. /DeviceRGB setcolorspace
  106. 3 RASTERMASK
  107. grestore
  108. } bind def
  109. /WINDOW {
  110. initclip
  111. exch
  112. 4 -1 roll
  113. 3 -1 roll 2 index sub
  114. 4 -1 roll 2 index sub
  115. rectclip
  116. } bind def
  117. /EPSWINDOW {
  118. exch
  119. 4 -1 roll
  120. 3 -1 roll 2 index sub
  121. 4 -1 roll 2 index sub
  122. rectclip
  123. } bind def
  124. /BEGIN {
  125. /Height exch def
  126. /Width exch def
  127. gsave
  128. } bind def
  129. /END {
  130. grestore
  131. showpage
  132. } bind def
  133. /NEW {
  134. newpath
  135. } bind def
  136. /MOVE {
  137. moveto
  138. } bind def
  139. /CONT {
  140. lineto
  141. } bind def
  142. /CLOSE {
  143. closepath
  144. } bind def
  145. /STROKE {
  146. stroke
  147. } bind def
  148. /FILL {
  149. eofill
  150. } bind def