/*
- * "$Id: image-tiff.c,v 1.14 2000/07/17 20:28:52 mike Exp $"
+ * "$Id: image-tiff.c,v 1.15 2000/07/18 19:45:52 mike Exp $"
*
* TIFF file routines for the Common UNIX Printing System (CUPS).
*
TIFF *tif; /* TIFF file */
uint32 width, height; /* Size of image */
uint16 photometric, /* Colorspace */
+ compression, /* Type of compression */
orientation, /* Orientation */
resunit, /* Units for resolution */
samples, /* Number of samples/pixel */
if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width) ||
!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height) ||
!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric) ||
+ !TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression) ||
!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samples) ||
!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits))
{
* each which must be handled separately...
*/
+ fprintf(stderr, "DEBUG: photometric = %d\n", photometric);
+ fprintf(stderr, "DEBUG: compression = %d\n", compression);
+
switch (photometric)
{
case PHOTOMETRIC_MINISWHITE :
case PHOTOMETRIC_MINISBLACK :
- if (photometric == PHOTOMETRIC_MINISBLACK)
+ if (photometric == PHOTOMETRIC_MINISWHITE)
{
- zero = 0;
- one = 255;
+ zero = 255;
+ one = 0;
}
else
{
- zero = 255;
- one = 0;
+ zero = 0;
+ one = 255;
}
if (orientation < ORIENTATION_LEFTTOP)
/*
- * End of "$Id: image-tiff.c,v 1.14 2000/07/17 20:28:52 mike Exp $".
+ * End of "$Id: image-tiff.c,v 1.15 2000/07/18 19:45:52 mike Exp $".
*/
/*
- * "$Id: imagetops.c,v 1.25 2000/06/27 19:01:58 mike Exp $"
+ * "$Id: imagetops.c,v 1.26 2000/07/18 19:45:52 mike Exp $"
*
* Image file to PostScript filter for the Common UNIX Printing System (CUPS).
*
ysize,
xsize2,
ysize2;
+ float aspect; /* Aspect ratio */
int xpages, /* # x pages */
ypages, /* # y pages */
xpage, /* Current x page */
float g; /* Gamma correction value */
float b; /* Brightness factor */
float zoom; /* Zoom facter */
- int ppi; /* Pixels-per-inch */
+ int xppi, yppi; /* Pixels-per-inch */
int hue, sat; /* Hue and saturation adjustment */
int realcopies; /* Real copies being printed */
float left, top; /* Left and top of image */
*/
zoom = 0.0;
- ppi = 0;
+ xppi = 0;
+ yppi = 0;
hue = 0;
sat = 100;
g = 1.0;
zoom = atoi(val) * 0.01;
if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
- ppi = atoi(val);
+ if (sscanf(val, "%dx%d", &xppi, &yppi) < 2)
+ yppi = xppi;
if ((val = cupsGetOption("position", num_options, options)) != NULL)
{
* Scale as necessary...
*/
- if (zoom == 0.0 && ppi == 0)
- ppi = img->xppi;
-
xprint = (PageRight - PageLeft) / 72.0;
yprint = (PageTop - PageBottom) / 72.0;
- if (ppi > 0)
+ if (zoom == 0.0 && xppi == 0)
+ {
+ xppi = img->xppi;
+ yppi = img->yppi;
+ }
+
+ if (yppi == 0)
+ yppi = xppi;
+
+ if (xppi > 0)
{
/*
* Scale the image as neccesary to match the desired pixels-per-inch.
*/
- xinches = (float)img->xsize / (float)ppi;
- yinches = (float)img->ysize / (float)ppi;
+ xinches = (float)img->xsize / (float)xppi;
+ yinches = (float)img->ysize / (float)yppi;
/*
* Rotate the image if it will fit landscape but not portrait...
* Scale percentage of page size...
*/
+ aspect = (float)img->yppi / (float)img->xppi;
+
+ fprintf(stderr, "DEBUG: img->xppi = %d, img->yppi = %d, aspect = %f\n",
+ img->xppi, img->yppi, aspect);
+
xsize = xprint * zoom;
- ysize = xsize * img->ysize / img->xsize;
+ ysize = xsize * img->ysize / img->xsize / aspect;
if (ysize > (yprint * zoom))
{
ysize = yprint * zoom;
- xsize = ysize * img->xsize / img->ysize;
+ xsize = ysize * img->xsize * aspect / img->ysize;
}
xsize2 = yprint * zoom;
- ysize2 = xsize2 * img->ysize / img->xsize;
+ ysize2 = xsize2 * img->ysize / img->xsize / aspect;
if (ysize2 > (xprint * zoom))
{
ysize2 = xprint * zoom;
- xsize2 = ysize2 * img->xsize / img->ysize;
+ xsize2 = ysize2 * img->xsize * aspect / img->ysize;
}
+ fprintf(stderr, "DEBUG: xsize = %.0f, ysize = %.0f\n", xsize, ysize);
+ fprintf(stderr, "DEBUG: xsize2 = %.0f, ysize2 = %.0f\n", xsize2, ysize2);
+
/*
* Choose the rotation with the largest area, but prefer
* portrait if they are equal...
/*
- * End of "$Id: imagetops.c,v 1.25 2000/06/27 19:01:58 mike Exp $".
+ * End of "$Id: imagetops.c,v 1.26 2000/07/18 19:45:52 mike Exp $".
*/
/*
- * "$Id: imagetoraster.c,v 1.45 2000/07/07 17:57:22 mike Exp $"
+ * "$Id: imagetoraster.c,v 1.46 2000/07/18 19:45:53 mike Exp $"
*
* Image file to raster filter for the Common UNIX Printing System (CUPS).
*
ysize,
xsize2,
ysize2;
+ float aspect; /* Aspect ratio */
int xpages, /* # x pages */
ypages, /* # y pages */
xpage, /* Current x page */
float g; /* Gamma correction value */
float b; /* Brightness factor */
float zoom; /* Zoom facter */
- int ppi; /* Pixels-per-inch */
+ int xppi, yppi; /* Pixels-per-inch */
int hue, sat; /* Hue and saturation adjustment */
izoom_t *z; /* ImageZoom buffer */
int primary, /* Primary image colorspace */
*/
zoom = 0.0;
- ppi = 0;
+ xppi = 0;
+ yppi = 0;
hue = 0;
sat = 100;
g = 1.0;
zoom = atoi(val) * 0.01;
if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
- ppi = atoi(val);
+ if (sscanf(val, "%dx%d", &xppi, &yppi) < 2)
+ yppi = xppi;
if ((val = cupsGetOption("position", num_options, options)) != NULL)
{
header.HWResolution[1] = 100;
header.cupsBitsPerColor = 1;
header.cupsColorOrder = CUPS_ORDER_CHUNKED;
- header.cupsColorSpace = CUPS_CSPACE_RGB;
+ header.cupsColorSpace = CUPS_CSPACE_K;
if ((choice = ppdFindMarkedChoice(ppd, "ColorModel")) != NULL)
exec_choice(&header, choice);
default :
primary = IMAGE_CMYK;
- secondary = IMAGE_CMYK;
+ secondary = IMAGE_BLACK;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
if (header.cupsBitsPerPixel == 1)
{
primary = IMAGE_CMY;
- secondary = IMAGE_CMY;
+ secondary = IMAGE_BLACK;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = 8;
else
{
primary = IMAGE_CMYK;
- secondary = IMAGE_CMYK;
+ secondary = IMAGE_BLACK;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
* Scale as necessary...
*/
- if (zoom == 0.0 && ppi == 0)
- ppi = img->xppi;
+ if (zoom == 0.0 && xppi == 0)
+ {
+ xppi = img->xppi;
+ yppi = img->yppi;
+ }
+
+ if (yppi == 0)
+ yppi = xppi;
- if (ppi > 0)
+ if (xppi > 0)
{
/*
* Scale the image as neccesary to match the desired pixels-per-inch.
yprint = (PageTop - PageBottom) / 72.0;
}
- xinches = (float)img->xsize / (float)ppi;
- yinches = (float)img->ysize / (float)ppi;
+ xinches = (float)img->xsize / (float)xppi;
+ yinches = (float)img->ysize / (float)yppi;
/*
* Rotate the image if it will fit landscape but not portrait...
xprint = (PageRight - PageLeft) / 72.0;
yprint = (PageTop - PageBottom) / 72.0;
+ aspect = (float)img->yppi / (float)img->xppi;
+
+ fprintf(stderr, "DEBUG: img->xppi = %d, img->yppi = %d, aspect = %f\n",
+ img->xppi, img->yppi, aspect);
xsize = xprint * zoom;
- ysize = xsize * img->ysize / img->xsize;
+ ysize = xsize * img->ysize / img->xsize / aspect;
if (ysize > (yprint * zoom))
{
ysize = yprint * zoom;
- xsize = ysize * img->xsize / img->ysize;
+ xsize = ysize * img->xsize * aspect / img->ysize;
}
xsize2 = yprint * zoom;
- ysize2 = xsize2 * img->ysize / img->xsize;
+ ysize2 = xsize2 * img->ysize / img->xsize / aspect;
if (ysize2 > (xprint * zoom))
{
ysize2 = xprint * zoom;
- xsize2 = ysize2 * img->xsize / img->ysize;
+ xsize2 = ysize2 * img->xsize * aspect / img->ysize;
}
+ fprintf(stderr, "DEBUG: xsize = %.0f, ysize = %.0f\n", xsize, ysize);
+ fprintf(stderr, "DEBUG: xsize2 = %.0f, ysize2 = %.0f\n", xsize2, ysize2);
+
/*
* Choose the rotation with the largest area, but prefer
* portrait if they are equal...
xpages = ceil(xinches / xprint);
ypages = ceil(yinches / yprint);
+ fprintf(stderr, "DEBUG: xpages = %d, ypages = %d\n", xpages, ypages);
+
/*
* Compute the bitmap size...
*/
/*
- * End of "$Id: imagetoraster.c,v 1.45 2000/07/07 17:57:22 mike Exp $".
+ * End of "$Id: imagetoraster.c,v 1.46 2000/07/18 19:45:53 mike Exp $".
*/
/*
- * "$Id: pstops.c,v 1.38 2000/05/30 20:49:51 mike Exp $"
+ * "$Id: pstops.c,v 1.39 2000/07/18 19:45:53 mike Exp $"
*
* PostScript filter for the Common UNIX Printing System (CUPS).
*
tbytes = atoi(strchr(line, ':') + 1);
while (tbytes > 0)
{
- nbytes = fread(line, 1, sizeof(line), fp);
+ if (tbytes > sizeof(line))
+ nbytes = fread(line, 1, sizeof(line), fp);
+ else
+ nbytes = fread(line, 1, tbytes, fp);
if (!sloworder)
fwrite(line, 1, nbytes, stdout);
/*
- * End of "$Id: pstops.c,v 1.38 2000/05/30 20:49:51 mike Exp $".
+ * End of "$Id: pstops.c,v 1.39 2000/07/18 19:45:53 mike Exp $".
*/