1
0

viewcmyk.ps 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. % Copyright (C) 1996, 1997, 1998 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: viewcmyk.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % viewcmyk.ps
  19. % Display a raw CMYK file.
  20. % Requires the colorimage operator.
  21. % If SCALE is defined, maps input pixels to output pixels with that scale;
  22. % if SCALE is undefined, scales the image to fit the page.
  23. % If BITS is defined, it is the number of bits per sample (1,2,4,8,12);
  24. % if BITS is undefined, its default value is 1.
  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. % If the program was invoked from the command line, run it now.
  52. [ shellarguments {
  53. counttomark 2 eq {
  54. cvi viewcmyk
  55. } {
  56. cleartomark
  57. (Usage: gs -- viewcmyk.ps filename.cmyk width\n) print
  58. ( e.g.: gs -- viewcmyk.ps my.cmyk 2550\n) print flush
  59. } ifelse
  60. } {
  61. pop
  62. } ifelse