星火微课系统客户端
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.

gs_icc.ps 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. % Copyright (C) 2001, 2002 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: gs_icc.ps 8962 2008-08-11 14:16:18Z ken $
  16. % ICCBased color space method dictionaries.
  17. % This assumes gs_ciecs2.ps has already been processed.
  18. .currentglobal true .setglobal
  19. % gs_res.ps uses these entries in colorspacedict
  20. % to populate the ColorSpaceFamily resource, so we need
  21. % to add the supported spaces.
  22. %
  23. systemdict /colorspacedict get begin
  24. /ICCBased [] def
  25. end
  26. NOPSICC { (%END PSICC) .skipeof } if
  27. % Now set up ICC profile loading for PostScript %%BeginICCProfile sections.
  28. systemdict begin
  29. /.ProcessICCcomment { % file comment -- file comment
  30. dup
  31. (%%BeginICCProfile) anchorsearch {
  32. pop pop
  33. DEBUG { (.ProcessICCcomment found %%BeginICCProfile) print flush } if
  34. % load an ICC profile defined as comments (hex encoded).
  35. % Ends with %%End at the start of a line. Read the data into
  36. % a bytestring to allow seeking. This string can be used as a
  37. % seekable ReusableStreamDecode filter source by the ICC logic.
  38. %
  39. % Since .bigstring needs to know the size, we first read an array of
  40. % strings each 64000 max length.
  41. %
  42. % stack: --file-- (%%BeginICCProfile: ...)
  43. 1 index 0 (%%EndICCProfile) /SubFileDecode filter
  44. [ { counttomark 1 add index
  45. 64000 string readhexstring
  46. not { exit } if
  47. } loop
  48. ] exch closefile
  49. 0 1 index { length add } forall
  50. .bigstring
  51. exch 0 exch {
  52. % stack: --file-- (%%BeginICCProfile: ...) --bytestring-- cur_index --string--
  53. 2 copy length add % calculate next string start point
  54. 3 1 roll 3 index 3 1 roll putinterval
  55. } forall
  56. pop % discard length of bytestring
  57. % make a seekable -file- out of the bytestring
  58. mark /AsyncRead true .dicttomark /ReusableStreamDecode filter
  59. % stack: --file-- (%%BeginICCProfile: ...) --icc_subfile--
  60. /DeviceCMYK setcolorspace
  61. << /DataSource 3 -1 roll
  62. /N 4 % Try CMYK first
  63. >> { .seticcspace } stopped {
  64. /DeviceRGB setcolorspace
  65. dup /N 3 put { .seticcspace } stopped {
  66. /DeviceGray setcolorspace
  67. dup /N 1 put { .seticcspace } stopped { % last choice
  68. QUIET not { ( *** Unable to load ICC profile from PostScript DSC comments ***) = flush } if
  69. pop
  70. } if
  71. } if
  72. } if
  73. } {
  74. pop % Not interested in this DSC comment
  75. } ifelse
  76. } bind def
  77. % Merge ProcessICCcomment with existing handler
  78. /.ProcessICCcomment load /exec load
  79. currentuserparams /ProcessDSCComment get
  80. dup null eq {pop {pop pop}} if /exec load
  81. 4 array astore cvx readonly
  82. << /ProcessDSCComment 3 -1 roll >> setuserparams
  83. end % systemdict
  84. %END PSICC
  85. .setglobal