home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 September / PCWorld_2001-09_cd.bin / Software / Vyzkuste / rychlokurz / gs700w32.exe / gs7.00 / lib / gs_icc.ps < prev    next >
Text File  |  2001-03-16  |  4KB  |  111 lines

  1. %    Copyright (C) 2001 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of AFPL Ghostscript.
  3. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  4. % distributor accepts any responsibility for the consequences of using it, or
  5. % for whether it serves any particular purpose or works at all, unless he or
  6. % she says so in writing.  Refer to the Aladdin Free Public License (the
  7. % "License") for full details.
  8. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. % in a plain ASCII text file named PUBLIC.  The License grants you the right
  10. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. % conditions described in the License.  Among other things, the License
  12. % requires that the copyright notice and this notice be preserved on all
  13. % copies.
  14.  
  15. % $Id: gs_icc.ps,v 1.1 2001/03/17 01:15:41 raph Exp $
  16. % PostScript portion of ICCBased color space support
  17.  
  18. //userdict /.icc_comp_map_dict
  19.   << 1 /DeviceGray  3 /DeviceRGB  4 /DeviceCMYK >>
  20. put
  21.  
  22. colorspacedict /ICCBased
  23.   {
  24.     % Verify that the source object is an array, that it is at least of length
  25.     % two, and that the second entry is a readable dictionary. If we got this
  26.     % far, we know the top-level object exists and is readable, but it might
  27.     % be a dictionary.
  28.     dup type dup /arraytype ne exch /packedarraytype ne and
  29.       { /setcolorspace /typecheck signalerror }
  30.     if
  31.     dup length 2 lt
  32.       { /setcolorspace /rangecheck signalerror }
  33.     if
  34.     dup 1 get type /dicttype ne
  35.       { /setcolorspace /typecheck signalerror }
  36.     if
  37.     dup 1 get rcheck not
  38.       { /setcolorspace /invalidaccess signalerror }
  39.     if
  40.  
  41.     % Verify that the dictionary defines the key N (number of components) and
  42.     %  entry is provided and has a legitimate value
  43.     dup 1 get /N .knownget
  44.       {
  45.         //.icc_comp_map_dict exch known not
  46.           { 
  47.             % generate the appropriate error
  48.             /setcolorspace 
  49.             1 index 1 get /N type type /integertype ne
  50.               { /typecheck }
  51.               { /rangecheck }
  52.             ifelse
  53.             signalerror
  54.           }
  55.         if
  56.       }
  57.       { /setcolorspace /undefined signalerror }
  58.     ifelse
  59.  
  60.     % Verify DataSrouce and, if it is a string, convert it to a file
  61.     dup 1 get /DataSource .knownget
  62.       {
  63.         dup rcheck not
  64.           { pop /setcolorspace /invalidaccess signalerror }
  65.         if
  66.         type dup /stringtype eq
  67.           {
  68.             pop
  69.             2 array copy
  70.             dup 1
  71.              2 copy get dup length dict copy
  72.              dup /DataSource
  73.               2 copy get /ReusableStreamDecode filter
  74.              put
  75.             put
  76.           }
  77.           {
  78.             /filetype ne
  79.               { /setcolorspace /typecheck signalerror }
  80.             if
  81.           }
  82.         ifelse
  83.       }
  84.       { /setcolorspace /undefined signalerror }
  85.     ifelse
  86.  
  87.     % set the alternate color space to be the current color space
  88.     dup 1 get /Alternate .knownget not
  89.       { dup 1 get /N get //.icc_comp_map_dict exch get }
  90.     if
  91.     setcolorspace
  92.  
  93.     % if CIE spaces are not use, just take the alternate space
  94.     NOCIE
  95.       { pop null }
  96.       {
  97.         % check for native support
  98.         /.seticcspace where
  99.           { pop dup 1 get .seticcspace }
  100.           { pop null }
  101.         ifelse
  102.       }
  103.     ifelse
  104.   }
  105. bind put
  106.  
  107. //userdict /.icc_comp_map_dict undef
  108.