home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 February / INTERNET88.ISO / pc / software / windows / bits / pdf995 / data1.cab / Program_Executable_Files / res / viewcmyk.ps < prev    next >
Encoding:
Text File  |  2001-12-08  |  2.4 KB  |  67 lines

  1. %    Copyright (C) 1996, 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of GNU Ghostscript.
  3. % GNU Ghostscript is distributed in the hope that it will be useful, but
  4. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  5. % to anyone for the consequences of using it or for whether it serves any
  6. % particular purpose or works at all, unless he says so in writing.  Refer
  7. % to the GNU General Public License for full details.
  8. % Everyone is granted permission to copy, modify and redistribute GNU
  9. % Ghostscript, but only under the conditions described in the GNU General
  10. % Public License.  A copy of this license is supposed to have been given
  11. % to you along with GNU Ghostscript so you can know your rights and
  12. % responsibilities.  It should be in a file named COPYING.  Among other
  13. % things, the copyright notice and this notice must be preserved on all
  14. % copies.
  15.  
  16. % $RCSfile: viewcmyk.ps,v $ $Revision: 1.2.2.1 $
  17. % viewcmyk.ps
  18. % Display a raw CMYK file.
  19. % Requires the colorimage operator.
  20. % If SCALE is defined, maps input pixels to output pixels with that scale;
  21. % if SCALE is undefined, scales the image to fit the page.
  22. % If BITS is defined, it is the number of bits per sample (1,2,4,8,12);
  23. % if BITS is undefined, its default value is 1.
  24.  
  25. /viewcmyk {            % <filename> <width> viewcmyk -
  26.   20 dict begin
  27.   /w exch def
  28.   /fname exch def
  29.   /bpc /BITS where { pop BITS } { 1 } ifelse def
  30.   /f fname (r) file def
  31.   mark fname status pop pop pop /flen exch def cleartomark
  32.   /h flen w bpc 4 mul mul 7 add 8 idiv idiv def
  33.   (Dimensions: ) print [w h] == flush
  34.         % Set up scaling.
  35.   /SCALE where {
  36.     pop
  37.     % Map pixels SCALE-for-1.  Assume orthogonal transformation.
  38.     SCALE 1 0 dtransform add abs div
  39.     SCALE 0 1 dtransform add abs div
  40.   } {
  41.     % Scale the image (uniformly) to fit the page.
  42.     clippath pathbbox pop pop translate
  43.     pathbbox 3 -1 roll sub h div
  44.     3 1 roll exch sub w div min dup
  45.   } ifelse scale
  46.   w h bpc [1 0 0 -1 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.   } ifelse
  61. } {
  62.   pop
  63. } ifelse
  64.