home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 September / PCWK996.iso / sharewar / 95 / narzedzi / ambra / ambr32a1.exe / FILE / ARCHIVE.Z / ACROBAT / VIEWER32.EXE / PSPROCSET / 8 < prev    next >
Text File  |  1996-02-22  |  3KB  |  115 lines

  1. %%BeginFile: pdfimg1b.prc
  2. %%Copyright: Copyright 1987-1993 Adobe Systems Incorporated. All Rights Reserved.
  3. % PDF Image Operators for Level 1 (Black and White)
  4.  
  5. PDF /PDFImage get begin
  6.  
  7. Level2? not StartLoad {
  8.  
  9. % The PDFImages dictionary contains image colorspace handlers.
  10. PDFIVars /PDFImages 4 dict put
  11.  
  12. % Utility funciton: InstallImage
  13. % Installs an image colorspace handler into the emulation.
  14. /InstallImage {
  15.     PDFIVars /PDFImages get 3 1 roll put
  16. } bd
  17.  
  18. % Utility functions: ColorComps? and ColorProc?
  19. % Obtain the number of color components and the image procedure for a 
  20. % particular colorspace.
  21. /ColorComps? {
  22.     dup type /arraytype eq { 0 get } if /PDFImages gv exch get 0 get
  23. } bd
  24. /ColorProc? {
  25.     dup type /arraytype eq { 0 get } if /PDFImages gv exch get 1 get
  26. } bd
  27.  
  28. % Utility function: ImageFilter
  29. % Determines the appropriate procedure to use with the image operator based
  30. % on the DataSource and Filter attributes in the image dictionary
  31. /ImageFilter {
  32.     /DataSource here {
  33.         pop [ DataSource ] cvx
  34.     }
  35.     {
  36.         % The only valid filter for Level 1 is ASCIIHexDecode.
  37.         % If Filter is not specified then the default is no filter,
  38.         % which indicates binary data.
  39.         /Filter here {
  40.             dup type /arraytype eq {
  41.                 dup length 1 ne {
  42.                     (Image uses unsupported cascading filters: ) print Filter == quit
  43.                 } {
  44.                     aload pop 
  45.                 } ifelse
  46.             } if
  47.             /ASCIIHexDecode ne {
  48.                 (Image uses unsupported filter: ) print Filter == quit
  49.             } {
  50.                  [ currentfile /CIBuffer gv /readhexstring cvx 
  51.                     /pop cvx ] cvx bind
  52.             } ifelse
  53.         } {
  54.              [ currentfile /CIBuffer gv /readstring cvx /pop cvx ] cvx bind
  55.         } ifelse
  56.     } ifelse    % /DataSource here not
  57. } bd
  58.  
  59.  
  60. % Image data
  61. /ID {                    % Image Node Contents
  62.     5 counttomark 2 idiv         % Number of key value pairs
  63.     dup 3 1 roll add            % Additional entries requested
  64.     dict begin                    % Create the dictionary
  65.         { def } repeat            % Def the key-value pairs into dict
  66.         cleartomark             % Get rid of the mark
  67.         currentdict             % Put the dictionary on the stack
  68.     end
  69.  
  70.     PDFIVars begin begin
  71.         % Establish default attributes if necessary
  72.         /ImageMatrix [ Width 0 0 Height neg 0 Height ] def
  73.         % Define ColorSpace since ColorComps?, ColorProc? need it
  74.         % Doesn't actually affect current color
  75.         /ColorSpace here { pop } 
  76.             { /ColorSpace /DeviceGray def } ifelse
  77.                 
  78.         % Calculate the buffer length in bytes:
  79.         %    ((Width * bpc * ncc) + 7) / 8
  80.         Width BitsPerComponent mul ColorSpace ColorComps? mul 
  81.         7 add 8 idiv 
  82.         string /CIBuffer exch pv
  83.  
  84.         % Now run the image
  85.         ColorSpace ColorProc? exec
  86.         /Filter here { % An ASCIIHex filter has a > terminator.
  87.             pop 
  88.             {
  89.                 currentfile read { 62 eq { exit } if } { exit } ifelse
  90.             } loop    % Get rid of hex EOD, YUCK!
  91.         } if
  92.     end end
  93. } bd
  94.  
  95. % Install the image DeviceGray colorspace handler.
  96. /DeviceGray [ 1
  97.     {
  98.         /ImageMask here not { false } if
  99.         {
  100.             sfc    % set Illustrator fill color
  101.             Width Height
  102.             /Decode here { 0 get 1 eq } { false } ifelse
  103.             ImageMatrix ImageFilter imagemask
  104.         } {
  105.             Width Height BitsPerComponent ImageMatrix 
  106.             ImageFilter image
  107.         } ifelse
  108.     } bind
  109. ] InstallImage
  110.  
  111. } EndLoad
  112.  
  113. end % PDFImage
  114. %%EndFile
  115.