1
0

stcolor.ps 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. % Copyright (C) 1995 Aladdin Enterprises. All rights reserved
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: stcolor.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  16. % stcolor.ps
  17. % Epson Stylus-Color Printer-Driver
  18. % The purpose of this file is to configure the stcolor-printer driver
  19. %
  20. % It is useless and dangerous to interpret the following code with anything
  21. % else than Ghostscript, so this condition is verified first. If this fails
  22. % a message is send to the output. If this message bothers you, remove it,
  23. % but I prefer to know why the device-setup failed.
  24. statusdict begin product end
  25. dup (Ghostscript) eq 1 index (Aladdin Ghostscript) eq or
  26. exch (AFPL Ghostscript) eq or{
  27. % fetch the current device-parameters this is specific for Ghostscript.
  28. /STCold currentdevice getdeviceprops .dicttomark def
  29. % Any Ghostscript-Driver has a Name, verify that the selected device is
  30. % stcolor, otherwise nothing than another message will be produced.
  31. STCold /Name get (stcolor) eq {
  32. %
  33. % The main thing this file does, is to establish transfer-functions.
  34. % Here are two predefined arrays for 360x360Dpi and for 720x720DpI.
  35. % If resolution is 360x720 or 720x360 the average is used. You may
  36. % want to define other arrays here.
  37. %
  38. /STCdeftransfer [ 0.0 1.0 ] def
  39. /STCKtransfer360 [
  40. 0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147
  41. 0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949
  42. 0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840
  43. 0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000
  44. ] def
  45. /STCKtransfer720 [
  46. 0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425
  47. 0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975
  48. 0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012
  49. 0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195
  50. ] def
  51. % compute the resolution
  52. STCold /HWResolution get dup
  53. 0 get exch 1 get mul sqrt /STCdpi exch def
  54. % pick the colormodel
  55. STCold /ProcessColorModel get /STCcolor exch def
  56. mark % prepare stack for "putdeviceprops"
  57. % warn for BitsPerPixel=30 with fsrgb
  58. STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and
  59. {
  60. (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n)
  61. print
  62. } if
  63. % if the Dithering-Method is default (gscmyk), change it to fscmyk
  64. % this is achieved by pushing a name/value-pair onto the stack
  65. % if the selected algorithm uses another ProcessColorModel, it is necessary
  66. % to change the Value of STCcolor according to the new algorithm.
  67. STCold /Dithering get (gscmyk) eq
  68. {
  69. /Dithering (hscmyk) % preferred dithering-method
  70. } if % might be necessary to change STCcolor too
  71. %
  72. % select the array according to the resolution
  73. %
  74. STCdpi 359.0 lt
  75. { STCdeftransfer }
  76. { STCdpi 361.0 lt
  77. { STCKtransfer360 }
  78. { STCdpi 719.0 gt
  79. { STCKtransfer720 }
  80. {
  81. STCKtransfer360 length STCKtransfer720 length eq
  82. {
  83. 0 1 STCKtransfer360 length 1 sub
  84. {
  85. dup dup
  86. STCKtransfer360 exch get
  87. exch STCKtransfer720 exch get
  88. add 2.0 div
  89. STCKtransfer360 3 1 roll put
  90. } for
  91. }if
  92. STCKtransfer360
  93. } ifelse
  94. }ifelse
  95. } ifelse
  96. /STCtransfer exch def
  97. %
  98. % Add the arrays. With Version 1.17 and above, it seems to be
  99. % a good idea, to use the transfer-arrays as coding-arrays too.
  100. %
  101. %
  102. % RGB-Model requires inversion of the transfer-arrays
  103. %
  104. STCcolor /DeviceRGB eq
  105. {
  106. /RGBtransfer STCtransfer length array def
  107. 0 1 STCtransfer length 1 sub
  108. {
  109. dup RGBtransfer length 1 sub exch sub exch
  110. STCtransfer exch get 1.0 exch sub
  111. RGBtransfer 3 1 roll put
  112. } for
  113. /Rtransfer RGBtransfer
  114. /Gtransfer RGBtransfer
  115. /Btransfer RGBtransfer
  116. /Rcoding RGBtransfer
  117. /Gcoding RGBtransfer
  118. /Bcoding RGBtransfer
  119. }{
  120. /Ctransfer STCtransfer
  121. /Mtransfer STCtransfer
  122. /Ytransfer STCtransfer
  123. /Ktransfer STCtransfer
  124. /Ccoding STCtransfer
  125. /Mcoding STCtransfer
  126. /Ycoding STCtransfer
  127. /Kcoding STCtransfer
  128. } ifelse
  129. counttomark 0 ne
  130. {currentdevice putdeviceprops pop}{cleartomark}ifelse
  131. % decativate predefined correction
  132. {} dup dup currenttransfer setcolortransfer
  133. }{
  134. (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print
  135. } ifelse
  136. }{
  137. (%%[ stcolor.ps: not interpreted by AFPL Ghostscript - ignored ]%%\n) print
  138. } ifelse