You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
4.9 KiB

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