% Copyright (C) 2001 Aladdin Enterprises. All rights reserved. % % This program is free software; you can redistribute it and/or modify it % under the terms of the GNU General Public License as published by the % Free Software Foundation; either version 2 of the License, or (at your % option) any later version. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 59 Temple Place, Suite 330, Boston, MA, 02111-1307. % $Id: gs_icc.ps,v 1.2.2.1.2.1 2003/04/12 14:02:38 giles Exp $ % PostScript portion of ICCBased color space support //userdict /.icc_comp_map_dict << 1 /DeviceGray 3 /DeviceRGB 4 /DeviceCMYK >> put colorspacedict /ICCBased { % Verify that the source object is an array, that it is at least of length % two, and that the second entry is a readable dictionary. If we got this % far, we know the top-level object exists and is readable, but it might % be a dictionary. dup type dup /arraytype ne exch /packedarraytype ne and { /setcolorspace /typecheck signalerror } if dup length 2 lt { /setcolorspace /rangecheck signalerror } if dup 1 get type /dicttype ne { /setcolorspace /typecheck signalerror } if dup 1 get rcheck not { /setcolorspace /invalidaccess signalerror } if % Verify that the dictionary defines the key N (number of components) and % entry is provided and has a legitimate value dup 1 get /N .knownget { //.icc_comp_map_dict exch known not { % generate the appropriate error /setcolorspace 1 index 1 get /N type type /integertype ne { /typecheck } { /rangecheck } ifelse signalerror } if } { /setcolorspace /undefined signalerror } ifelse % Verify DataSrouce and, if it is a string, convert it to a file dup 1 get /DataSource .knownget { dup rcheck not { pop /setcolorspace /invalidaccess signalerror } if type dup /stringtype eq { pop 2 array copy dup 1 2 copy get dup length dict copy dup /DataSource 2 copy get /ReusableStreamDecode filter put put } { /filetype ne { /setcolorspace /typecheck signalerror } if } ifelse } { /setcolorspace /undefined signalerror } ifelse % set the alternate color space to be the current color space dup 1 get /Alternate .knownget not { dup 1 get /N get //.icc_comp_map_dict exch get } if setcolorspace % if CIE spaces are not use, just take the alternate space NOCIE { pop //null } { % check for native support /.seticcspace where { pop dup 1 get % Acrobat Reader silently ignores errors with ICC profiles % and uses the alternate color space -- do the same. mark exch { .seticcspace } stopped { cleartomark pop //null } { pop } ifelse } { pop //null } ifelse } ifelse } bind put //userdict /.icc_comp_map_dict undef