diff options
Diffstat (limited to 'Master/tlpkg/tlgs/lib/viewpcx.ps')
-rw-r--r-- | Master/tlpkg/tlgs/lib/viewpcx.ps | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/Master/tlpkg/tlgs/lib/viewpcx.ps b/Master/tlpkg/tlgs/lib/viewpcx.ps index 17d180f5b8a..288049897ac 100644 --- a/Master/tlpkg/tlgs/lib/viewpcx.ps +++ b/Master/tlpkg/tlgs/lib/viewpcx.ps @@ -1,4 +1,5 @@ -% Copyright (C) 1996, 1999 Aladdin Enterprises. All rights reserved. +% Copyright (C) 2001-2012 Artifex Software, Inc. +% All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or % implied. @@ -7,18 +8,17 @@ % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % -% For more information about licensing, please refer to -% http://www.ghostscript.com/licensing/. For information on -% commercial licensing, go to http://www.artifex.com/licensing/ or -% contact Artifex Software, Inc., 101 Lucas Valley Road #110, -% San Rafael, CA 94903, U.S.A., +1(415)492-9861. +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, +% CA 94903, U.S.A., +1(415)492-9861, for further information. +% -% $Id$ % viewpcx.ps % Display a PCX file. % Requires the Level 2 `image' operator (to handle variable pixel widths). % If SCALE is defined, maps input pixels to output pixels with that scale; % if SCALE is undefined, scales the image to fit the page. +% If FITPAGE is true it fits the output page size to the image, honouring SCALE % ****NOTE: does not handle multi-plane images with palette. /pcxbytes [ @@ -57,6 +57,31 @@ /bpp header 3 get def /w header 8 get2 header 4 get2 sub 1 add def /h header 10 get2 header 6 get2 sub 1 add def + /FITPAGE where + { + /FITPAGE get + { + 5 dict begin + /SCALE where + { + pop + /Width w SCALE mul def + /Height h SCALE mul def + } + { + /Width w def + /Height h def + } ifelse + % we've already set the image color space, so + % push it on the stack, and set it again after + % setting the page size + <</PageSize [Width Height] >> setpagedevice + end + } if + } + { + /FITPAGE false def + } ifelse /nplanes header 65 get def /bpl header 66 get2 def /palinfo header 68 get2 def @@ -88,15 +113,31 @@ ifelse % Set up scaling. /SCALE where - { pop + { + pop + FITPAGE + { + % Map pixels SCALE-for-1. Assume orthogonal transformation. + w SCALE mul + h SCALE mul + } + { % Map pixels SCALE-for-1. Assume orthogonal transformation. - w 1 0 dtransform add abs div SCALE mul - h 0 1 dtransform add abs div SCALE mul + w 1 0 dtransform add abs div SCALE mul + h 0 1 dtransform add abs div SCALE mul + } ifelse } - { % Scale the image (uniformly) to fit the page. - clippath pathbbox pop pop translate - pathbbox .min exch pop exch pop ceiling - dup h w gt { w mul h div exch } { h mul w div } ifelse + { + FITPAGE + { + w h + } + { + % Scale the image (uniformly) to fit the page. + clippath pathbbox pop pop translate + pathbbox .min exch pop exch pop ceiling + dup h w gt { w mul h div exch } { h mul w div } ifelse + } ifelse } ifelse scale % Since the number of bytes per line is always even, |