home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / gs403osk.tgz / gs403osk.tar / viewcmyk.ps < prev    next >
Text File  |  1996-09-22  |  2KB  |  66 lines

  1. %    Copyright (C) 1996 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % viewcmyk.ps
  20. % Display a 1-bit-per-component CMYK file.
  21. % Requires the colorimage operator.
  22. % If SCALE is defined, maps input pixels to output pixels with that scale;
  23. % if SCALE is undefined, scales the image to fit the page.
  24.  
  25. /viewcmyk           % <filename> <width> viewcmyk -
  26.  { 20 dict begin
  27.    /w exch def
  28.    /fname exch def
  29.    /f fname (r) file def
  30.    mark fname status pop pop pop /flen exch def cleartomark
  31.    /h flen w 1 add 2 idiv idiv def
  32.    (Dimensions: ) print [w h] == flush
  33.         % Set up scaling.
  34.    /SCALE where
  35.     { pop
  36.     % Map pixels SCALE-for-1.  Assume orthogonal transformation.
  37.       w 1 0 dtransform add abs div SCALE mul
  38.       h 0 1 dtransform add abs div SCALE mul
  39.     }
  40.     {   % Scale the image (uniformly) to fit the page.
  41.       clippath pathbbox pop pop translate
  42.       pathbbox 4 2 roll pop pop
  43.       h div w mul min dup
  44.     }
  45.    ifelse scale
  46.    w h 1 [w 0 0 h neg 0 h] f false 4 colorimage
  47.    showpage
  48.    f closefile
  49.    end
  50.  } bind def
  51.  
  52. % If the program was invoked from the command line, run it now.
  53. [ shellarguments
  54.  { counttomark 2 eq
  55.     { cvi viewcmyk
  56.     }
  57.     { cleartomark
  58.       (Usage: gs -- viewcmyk.ps filename.cmyk width\n) print
  59.       ( e.g.: gs -- viewcmyk.ps my.cmyk 2550\n) print flush
  60.     }
  61.    ifelse
  62.  }
  63.  { pop
  64.  }
  65. ifelse
  66.