From Helge (libtiff@oldach.net)
Here's a fix for fax2ps that corrects behaviour for non-Letter paper sizes. It fixes two problems: Without scaling (-S) the fax is now centered on the page size specified with -H and/or -W. Before, fax2ps was using an obscure and practially useless algorithm to allocate the image relative to Letter sized paper which sometime sled to useless whitespace on the paper, while at the same time cutting of the faxes printable area at the opposite border. Second, scaling now preserves aspect ratio, which makes unusual faxes (in particular short ones) print properly.
This commit is contained in:
parent
a4079e754e
commit
4f4c99abfc
16
ChangeLog
16
ChangeLog
@ -1,5 +1,21 @@
|
||||
2001-03-28 Frank Warmerdam <warmerdam@pobox.com>
|
||||
|
||||
* fax2ps.c: Helge (libtiff at oldach.net) submitted fix:
|
||||
|
||||
Here's a fix for fax2ps that corrects behaviour for non-Letter paper
|
||||
sizes. It fixes two problems:
|
||||
|
||||
Without scaling (-S) the fax is now centered on the page size specified
|
||||
with -H and/or -W. Before, fax2ps was using an obscure and practially
|
||||
useless algorithm to allocate the image relative to Letter sized paper
|
||||
which sometime sled to useless whitespace on the paper, while at the
|
||||
same time cutting of the faxes printable area at the opposite border.
|
||||
|
||||
Second, scaling now preserves aspect ratio, which makes unusual faxes
|
||||
(in particular short ones) print properly.
|
||||
|
||||
See http://bugzilla.remotesensing.org/show_bug.cgi?id=35
|
||||
|
||||
* tiff2ps.c/tiff2ps.1: Substantial changes to tiff2ps by
|
||||
Bruce A. Mallett. See check message for detailed information
|
||||
on all the changes, including a faster encoder, fixes for level
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/tools/fax2ps.c,v 1.4 2000-03-28 18:22:59 warmerda Exp $" */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/tools/fax2ps.c,v 1.5 2001-03-29 01:45:43 warmerda Exp $" */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@ -155,7 +155,7 @@ printTIF(TIFF* tif, int pageNumber)
|
||||
{
|
||||
uint32 w, h;
|
||||
uint16 unit;
|
||||
float xres, yres;
|
||||
float xres, yres, scale = 1.0;
|
||||
tstrip_t s, ns;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
|
||||
@ -178,21 +178,13 @@ printTIF(TIFF* tif, int pageNumber)
|
||||
|
||||
printf("%%%%Page: \"%d\" %d\n", pageNumber, pageNumber);
|
||||
printf("/$pageTop save def gsave\n");
|
||||
if (scaleToPage) {
|
||||
float yscale = pageHeight / (h/yres);
|
||||
float xscale = pageWidth / (w/xres);
|
||||
printf("%d %d translate\n",
|
||||
(int) (((basePageWidth - pageWidth) * points) * half),
|
||||
(int)((yscale*(h/yres)*points) +
|
||||
(basePageHeight - pageHeight) * points * half) );
|
||||
printf("%g %g scale\n", (72.*xscale)/xres, -(72.*yscale)/yres);
|
||||
} else {
|
||||
printf("%d %d translate\n",
|
||||
(int) ((basePageWidth - pageWidth) * points * half),
|
||||
(int)((72.*h/yres) +
|
||||
(basePageHeight - pageHeight) * points * half) );
|
||||
printf("%g %g scale\n", 72./xres, -72./yres);
|
||||
}
|
||||
if (scaleToPage)
|
||||
scale = pageHeight / (h/yres) < pageWidth / (w/xres) ?
|
||||
pageHeight / (h/yres) : pageWidth / (w/xres);
|
||||
printf("%g %g translate\n",
|
||||
points * (pageWidth - scale*w/xres) * half,
|
||||
points * (scale*h/yres + (pageHeight - scale*h/yres) * half));
|
||||
printf("%g %g scale\n", points/xres*scale, -points/yres*scale);
|
||||
printf("0 setgray\n");
|
||||
TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, printruns);
|
||||
ns = TIFFNumberOfStrips(tif);
|
||||
|
Loading…
Reference in New Issue
Block a user