stcolor.ps 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. % Copyright (C) 1995 Aladdin Enterprises. All rights reserved
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: stcolor.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % stcolor.ps
  19. % Epson Stylus-Color Printer-Driver
  20. % The purpose of this file is to configure the stcolor-printer driver
  21. %
  22. % It is useless and dangerous to interpret the following code with anything
  23. % else than Ghostscript, so this condition is verified first. If this fails
  24. % a message is send to the output. If this message bothers you, remove it,
  25. % but I prefer to know why the device-setup failed.
  26. statusdict begin product end
  27. dup (Ghostscript) eq 1 index (Aladdin Ghostscript) eq or
  28. exch (AFPL Ghostscript) eq or{
  29. % fetch the current device-parameters this is specific for Ghostscript.
  30. /STCold currentdevice getdeviceprops .dicttomark def
  31. % Any Ghostscript-Driver has a Name, verify that the selected device is
  32. % stcolor, otherwise nothing than another message will be produced.
  33. STCold /Name get (stcolor) eq {
  34. %
  35. % The main thing this file does, is to establish transfer-functions.
  36. % Here are two predefined arrays for 360x360Dpi and for 720x720DpI.
  37. % If resolution is 360x720 or 720x360 the average is used. You may
  38. % want to define other arrays here.
  39. %
  40. /STCdeftransfer [ 0.0 1.0 ] def
  41. /STCKtransfer360 [
  42. 0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147
  43. 0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949
  44. 0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840
  45. 0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000
  46. ] def
  47. /STCKtransfer720 [
  48. 0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425
  49. 0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975
  50. 0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012
  51. 0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195
  52. ] def
  53. % compute the resolution
  54. STCold /HWResolution get dup
  55. 0 get exch 1 get mul sqrt /STCdpi exch def
  56. % pick the colormodel
  57. STCold /ProcessColorModel get /STCcolor exch def
  58. mark % prepare stack for "putdeviceprops"
  59. % warn for BitsPerPixel=30 with fsrgb
  60. STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and
  61. {
  62. (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n)
  63. print
  64. } if
  65. % if the Dithering-Method is default (gscmyk), change it to fscmyk
  66. % this is achieved by pushing a name/value-pair onto the stack
  67. % if the selected algorithm uses another ProcessColorModel, it is necessary
  68. % to change the Value of STCcolor according to the new algorithm.
  69. STCold /Dithering get (gscmyk) eq
  70. {
  71. /Dithering (hscmyk) % preferred dithering-method
  72. } if % might be necessary to change STCcolor too
  73. %
  74. % select the array according to the resolution
  75. %
  76. STCdpi 359.0 lt
  77. { STCdeftransfer }
  78. { STCdpi 361.0 lt
  79. { STCKtransfer360 }
  80. { STCdpi 719.0 gt
  81. { STCKtransfer720 }
  82. {
  83. STCKtransfer360 length STCKtransfer720 length eq
  84. {
  85. 0 1 STCKtransfer360 length 1 sub
  86. {
  87. dup dup
  88. STCKtransfer360 exch get
  89. exch STCKtransfer720 exch get
  90. add 2.0 div
  91. STCKtransfer360 3 1 roll put
  92. } for
  93. }if
  94. STCKtransfer360
  95. } ifelse
  96. }ifelse
  97. } ifelse
  98. /STCtransfer exch def
  99. %
  100. % Add the arrays. With Version 1.17 and above, it seems to be
  101. % a good idea, to use the transfer-arrays as coding-arrays too.
  102. %
  103. %
  104. % RGB-Model requires inversion of the transfer-arrays
  105. %
  106. STCcolor /DeviceRGB eq
  107. {
  108. /RGBtransfer STCtransfer length array def
  109. 0 1 STCtransfer length 1 sub
  110. {
  111. dup RGBtransfer length 1 sub exch sub exch
  112. STCtransfer exch get 1.0 exch sub
  113. RGBtransfer 3 1 roll put
  114. } for
  115. /Rtransfer RGBtransfer
  116. /Gtransfer RGBtransfer
  117. /Btransfer RGBtransfer
  118. /Rcoding RGBtransfer
  119. /Gcoding RGBtransfer
  120. /Bcoding RGBtransfer
  121. }{
  122. /Ctransfer STCtransfer
  123. /Mtransfer STCtransfer
  124. /Ytransfer STCtransfer
  125. /Ktransfer STCtransfer
  126. /Ccoding STCtransfer
  127. /Mcoding STCtransfer
  128. /Ycoding STCtransfer
  129. /Kcoding STCtransfer
  130. } ifelse
  131. counttomark 0 ne
  132. {currentdevice putdeviceprops pop}{cleartomark}ifelse
  133. % decativate predefined correction
  134. {} dup dup currenttransfer setcolortransfer
  135. }{
  136. (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print
  137. } ifelse
  138. }{
  139. (%%[ stcolor.ps: not interpreted by AFPL Ghostscript - ignored ]%%\n) print
  140. } ifelse