AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
June 2007

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2007.06.28 13:20 "patches to tiff2ps-3.8.2 for 16 bit samples", by William Bader
2007.06.29 14:01 "Re: patches to tiff2ps-3.8.2 for 16 bit samples", by William Bader

2007.06.29 14:01 "Re: patches to tiff2ps-3.8.2 for 16 bit samples", by William Bader

The patches are at http://williambader.com/pat/tiff-3.8.2.pat
and below:
--- tiff-3.8.2/tools/tiff2ps.c- 2006-03-03 13:09:45.000000000 +0100
+++ tiff-3.8.2/tools/tiff2ps.c  2007-06-20 14:17:52.000000000 +0200
@@ -350,6 +350,8 @@
        switch (bitspersample) {
        case 1: case 2:
        case 4: case 8:
+       /* wb 20Ju07 allow 16 bits */
+       case 16:
                break;
        default:
                TIFFError(filename, "Can not handle %d-bit/sample image",
@@ -434,7 +436,9 @@
                break;
        case RESUNIT_NONE:
        default:
-               xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE;
+               /* wb 20Jun07 check that the resolution is not inches before 
scaling it */
+               if (xres != PS_UNIT_SIZE || yres != PS_UNIT_SIZE)
+                       xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE;
                break;
        }
        *pprh = PSUNITS(*ph, yres);
@@ -1173,6 +1177,26 @@
        return(use_rawdata);
}

+/* Flip the byte order of buffers with 16 bit samples */
+static void
+PS_FlipBytes(char* buf, int count)
+{
+       int i;
+       char temp;
+
+       if (count <= 0 || bitspersample <= 8) {
+               return;
+       }
+
+       count--;
+
+       for (i = 0; i < count; i += 2) {
+               temp = buf[ i ];
+               buf[ i ] = buf[ i + 1 ];
+               buf[ i + 1 ] = temp;
+       }
+}
+
#define MAXLINE                36

int
@@ -1278,6 +1302,10 @@
                        if (ascii85)
                                Ascii85Put('\0', fd);
                }
+               /* wb 20Jun07 for 16 bits, the two bytes must be most 
significant byte first */
+               if (bitspersample == 16 && !TIFFIsBigEndian(tif)) {
+                       PS_FlipBytes(buf_data, byte_count);
+               }
                /*
                 * For images with alpha, matte against a white background;
                 * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill 
the
@@ -1476,6 +1504,10 @@
                if (TIFFReadScanline(tif, tf_buf, row, 0) < 0)
                        break;
                cp = tf_buf;
+               /* wb 20Jun07 for 16 bits, the two bytes must be most 
significant byte first */
+               if (bitspersample == 16 && !HOST_BIGENDIAN) {
+                       PS_FlipBytes(cp, tf_bytesperrow);
+               }
                if (alpha) {
                        int adjust;
                        cc = 0;
@@ -1677,6 +1709,10 @@
                                *cp = ~*cp;
                        cp++;
                }
+               /* wb 20Jun07 for 16 bits, the two bytes must be most 
significant byte first */
+               if (bitspersample == 16 && !HOST_BIGENDIAN) {
+                       PS_FlipBytes(cp, cc);
+               }
                if (ascii85) {
#if defined( EXP_ASCII85ENCODER )
                        if (alpha) {

_________________________________________________________________
Hotmail to go? Get your Hotmail, news, sports and much more! 
http://mobile.msn.com