1 % Copyright (C) 1996, 1997, 1998 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
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.
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.
16 % $Id: viewcmyk.ps,v 1.5 2002/06/02 12:03:28 mpsuzuki Exp $
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.
25 /viewcmyk { % <filename> <width> viewcmyk -
29 /bpc /BITS where { pop BITS } { 1 } ifelse 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
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
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
46 w h bpc [1 0 0 -1 0 h] f false 4 colorimage
52 % If the program was invoked from the command line, run it now.
58 (Usage: gs -- viewcmyk.ps filename.cmyk width\n) print
59 ( e.g.: gs -- viewcmyk.ps my.cmyk 2550\n) print flush