1
0

gs_icc.ps 3.5 KB

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