home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / stcolor.ps < prev    next >
Text File  |  2000-03-09  |  5KB  |  173 lines

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