]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/viewcmyk.ps
merge
[plan9front.git] / sys / lib / ghostscript / viewcmyk.ps
1 %    Copyright (C) 1996, 1997, 1998 Aladdin Enterprises.  All rights reserved.
2
3 % This software is provided AS-IS with no warranty, either express or
4 % implied.
5
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.
9
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.
15
16 % $Id: viewcmyk.ps,v 1.5 2002/06/02 12:03:28 mpsuzuki Exp $
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