]> granicus.if.org Git - openjpeg/commitdiff
Enabled compression of TIF image format to j2k by tifftoimage() and decompression...
authorParvatha Elangovan <p.elangovan@intopix.com>
Wed, 28 Feb 2007 15:31:56 +0000 (15:31 +0000)
committerParvatha Elangovan <p.elangovan@intopix.com>
Wed, 28 Feb 2007 15:31:56 +0000 (15:31 +0000)
13 files changed:
ChangeLog
codec/convert.c
codec/convert.h
codec/image_to_j2k.c
codec/j2k_to_image.c
libopenjpeg/openjpeg.h
libs/libtiff/Tiffcomp.h [new file with mode: 0644]
libs/libtiff/Tiffconf.h [new file with mode: 0644]
libs/libtiff/Tiffiop.h [new file with mode: 0644]
libs/libtiff/Version.h [new file with mode: 0644]
libs/libtiff/libtiff.lib [new file with mode: 0644]
libs/libtiff/tiff.h [new file with mode: 0644]
libs/libtiff/tiffio.h [new file with mode: 0644]

index baa216c9ef75540cd1fb55e6575fd7b5282b13dc..10bf62e0bdb3e8592c4c1cdf7f1481e08daf49eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ What's New for OpenJPEG
 + : added
 
 February 28, 2007
++ [Parvatha] Enabled compression of TIF image format to j2k by tifftoimage() and decompression of codestream to TIF image format using imagetotif(). Modifications in image_to_j2k.c, j2k_to_image.c, convert.c, convert.h
 * [antonin] fixed a bug in context numerotation that prevented the RESET switch to work correctly : mqc_reset_enc in mqc.c
 * [Fod] Corrected codec Makefile by adding the compilation of "compat/getopt.c" 
 
index 5c84cbdbcdf88b7876a736760eb7bb68095d6ac7..3ff6eb88d2d6af3aff587eebd862f3d8b63d353b 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "openjpeg.h"
+#include "../libs/libtiff/tiffio.h"
 
 /*
  * Get logarithm of an integer and round downwards.
@@ -1063,4 +1064,359 @@ int imagetopnm(opj_image_t * image, const char *outfile) {
        return 0;
 }
 
+/* -->> -->> -->> -->>
+
+       TIFF IMAGE FORMAT
+
+ <<-- <<-- <<-- <<-- */
+
+typedef struct tiff_infoheader{
+       DWORD tiWidth;  // Width of Image in pixel
+       DWORD tiHeight; // Height of Image in pixel
+       DWORD tiPhoto;  // Photometric
+       WORD  tiBps;    // Bits per sample
+       WORD  tiSf;             // Sample Format
+       WORD  tiSpp;    // Sample per pixel 1-bilevel,gray scale , 2- RGB
+       WORD  tiPC;     // Planar config (1-Interleaved, 2-Planarcomp)
+}tiff_infoheader_t;
+
+int imagetotif(opj_image_t * image, const char *outfile) {
+       int width, height;
+       int bps,index;
+       TIFF *tif;
+       tdata_t buf;
+       tstrip_t strip;
+       tsize_t strip_size;
 
+       if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
+               && image->comps[1].dx == image->comps[2].dx
+               && image->comps[0].dy == image->comps[1].dy
+               && image->comps[1].dy == image->comps[2].dy
+               && image->comps[0].prec == image->comps[1].prec
+               && image->comps[1].prec == image->comps[2].prec) {
+
+                       /* -->> -->> -->>    
+                       RGB color           
+                       <<-- <<-- <<-- */
+
+                       tif = TIFFOpen(outfile, "wb"); 
+                       if (!tif) {
+                               fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
+                               return 1;
+                       }
+
+                       width   = image->comps[0].w;
+                       height= image->comps[0].h;
+                       bps             = image->comps[0].prec;
+                       /* Set tags */
+                       TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
+                       TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
+                       TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
+                       TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
+                       TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+                       TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+                       TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+                       TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
+
+                       /* Get a buffer for the data */
+                       buf = _TIFFmalloc(TIFFStripSize(tif));
+                       index=0;
+                       strip_size=0;
+                       strip_size=TIFFStripSize(tif);
+                       for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
+                               unsigned char *dat8;
+                               int i;
+                               dat8 = buf;
+                               if (image->comps[0].prec == 8){
+                                       for (i=0; i<TIFFStripSize(tif); i+=3) { // 8 bits per pixel 
+                                               dat8[i+0] = image->comps[0].data[index] ;       // R 
+                                               dat8[i+1] = image->comps[1].data[index] ;       // G 
+                                               dat8[i+2] = image->comps[2].data[index] ;       // B 
+                                               index++;
+                                       }
+                               }else if (image->comps[0].prec == 12){
+                                       for (i=0; i<TIFFStripSize(tif); i+=9) { // 12 bits per pixel 
+                                               dat8[i+0] = (image->comps[0].data[index]>>8)<<4 | (image->comps[0].data[index]>>4);
+                                               dat8[i+1] = (image->comps[0].data[index]<<4)|((image->comps[1].data[index]>>8)& 0x0f);
+                                               dat8[i+2] = (image->comps[1].data[index]);
+                                               dat8[i+3] = (image->comps[2].data[index]>>8)<<4 | (image->comps[2].data[index]>>4);
+                                               dat8[i+4] = (image->comps[2].data[index]<<4)|((image->comps[1].data[index+1]>>8)& 0x0f);
+                                               dat8[i+5] = (image->comps[0].data[index+1]);
+                                               dat8[i+6] = (image->comps[1].data[index+1]>>8)<<4 | (image->comps[1].data[index+1]>>4);
+                                               dat8[i+7] = (image->comps[1].data[index+1]<<4)|((image->comps[2].data[index+1]>>8)& 0x0f);
+                                               dat8[i+8] = (image->comps[2].data[index+1]);
+                                               index+=2;
+                                       }
+                               }else if (image->comps[0].prec == 16){
+                                       for (i=0; i<TIFFStripSize(tif); i+=6) { // 16 bits per pixel 
+                                               dat8[i+0] =  image->comps[0].data[index];//LSB
+                                               dat8[i+1] = (image->comps[0].data[index]>> 8);//MSB      
+                                               dat8[i+2] =  image->comps[1].data[index]; 
+                                               dat8[i+3] = (image->comps[1].data[index]>> 8);  
+                                               dat8[i+4] =  image->comps[2].data[index];        
+                                               dat8[i+5] = (image->comps[2].data[index]>> 8); 
+                                               index++;
+                                       }
+                               }else{
+                                       fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
+                                       fprintf(stderr,"Aborting\n");
+                                       return 1;
+                               }
+                               TIFFWriteEncodedStrip(tif, strip, buf, strip_size);
+                       }
+                       _TIFFfree(buf);
+                       TIFFClose(tif);
+               }else if (image->numcomps == 1){
+                       /* -->> -->> -->>    
+                       Black and White     
+                       <<-- <<-- <<-- */
+
+                       tif = TIFFOpen(outfile, "wb"); 
+                       if (!tif) {
+                               fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
+                               return 1;
+                       }
+
+                       width   = image->comps[0].w;
+                       height= image->comps[0].h;
+                       bps             = image->comps[0].prec;
+
+                       /* Set tags */
+                       TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
+                       TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
+                       TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
+                       TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
+                       TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+                       TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+                       TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+                       TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
+
+                       /* Get a buffer for the data */
+                       buf = _TIFFmalloc(TIFFStripSize(tif));
+                       index = 0;
+                       strip_size = 0;
+                       strip_size = TIFFStripSize(tif);
+                       for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
+                               unsigned char *dat8;
+                               int i;
+                               dat8 = buf;
+                               if (image->comps[0].prec == 8){
+                                       for (i=0; i<TIFFStripSize(tif); i+=1) { // 8 bits per pixel 
+                                               dat8[i+0] = image->comps[0].data[index] ;
+                                               index++;
+                                       }
+                               }else if (image->comps[0].prec == 12){
+                                       for (i = 0; i<TIFFStripSize(tif); i+=3) {       // 12 bits per pixel 
+                                               dat8[i+0] = (image->comps[0].data[index]>>8)<<4 | (image->comps[0].data[index]>>4);
+                                               dat8[i+1] = (image->comps[0].data[index]<<4)|((image->comps[0].data[index+1]>>8)& 0x0f);
+                                               dat8[i+2] = (image->comps[0].data[index+1]);
+                                               index+=2;
+                                       }
+                               }else if (image->comps[0].prec == 16){
+                                       for (i=0; i<TIFFStripSize(tif); i+=2) { // 16 bits per pixel 
+                                               dat8[i+0] =  image->comps[0].data[index];
+                                               dat8[i+1] = (image->comps[0].data[index]>> 8);
+                                               index++;
+                                       }
+                               }else{
+                                       fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
+                                       fprintf(stderr,"Aborting\n");
+                                       return 1;
+                               }
+                               TIFFWriteEncodedStrip(tif, strip, buf, strip_size);
+                       }
+                       _TIFFfree(buf);
+                       TIFFClose(tif);
+               }else{
+                       fprintf(stderr,"False color format. Only RGB & Grayscale has been implemented\n");
+                       fprintf(stderr,"Aborting\n");
+                       return 1;
+               }
+               return 0;
+}
+
+opj_image_t* tiftoimage(char *filename, opj_cparameters_t *parameters)
+{
+       int subsampling_dx = parameters->subsampling_dx;
+       int subsampling_dy = parameters->subsampling_dy;
+       TIFF *tif;
+       tiff_infoheader_t Info;
+       tdata_t buf;
+       tstrip_t strip;
+       tsize_t strip_size;
+       int j, numcomps, w, h,index;
+       OPJ_COLOR_SPACE color_space;
+       opj_image_cmptparm_t cmptparm[3];
+       opj_image_t * image = NULL;
+
+       tif = TIFFOpen(filename, "r");
+
+       if (!tif) {
+               fprintf(stderr, "Failed to open %s for reading\n", filename);
+               return 0;
+       }
+
+       TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &Info.tiWidth);
+       TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &Info.tiHeight);
+       TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &Info.tiBps);
+       TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &Info.tiSf);
+       TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &Info.tiSpp);
+       Info.tiPhoto = 0;
+       TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &Info.tiPhoto);
+       TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &Info.tiPC);
+       w= Info.tiWidth;
+       h= Info.tiHeight;
+
+       if (Info.tiPhoto == 2) { 
+               /* -->> -->> -->>    
+               RGB color           
+               <<-- <<-- <<-- */
+
+               numcomps = 3;
+               color_space = CLRSPC_SRGB;
+               /* initialize image components*/ 
+               memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
+               for(j = 0; j < numcomps; j++) {
+                       cmptparm[j].prec = Info.tiBps;
+                       cmptparm[j].bpp = Info.tiBps;
+                       cmptparm[j].sgnd = 0;
+                       cmptparm[j].dx = subsampling_dx;
+                       cmptparm[j].dy = subsampling_dy;
+                       cmptparm[j].w = w;
+                       cmptparm[j].h = h;
+               }
+               /* create the image*/ 
+               image = opj_image_create(numcomps, &cmptparm[0], color_space);
+               if(!image) {
+                       TIFFClose(tif);
+                       return NULL;
+               }
+
+               /* set image offset and reference grid */
+               image->x0 = parameters->image_offset_x0;
+               image->y0 = parameters->image_offset_y0;
+               image->x1 =     !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
+               image->y1 =     !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
+
+               buf = _TIFFmalloc(TIFFStripSize(tif));
+               strip_size=0;
+               strip_size=TIFFStripSize(tif);
+               index = 0;
+               /* Read the Image components*/
+               for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
+                       unsigned char *dat8;
+                       int i, ssize;
+                       ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
+                       dat8 = buf;
+
+                       if (Info.tiBps==12){
+                               for (i=0; i<ssize; i+=9) {      /*12 bits per pixel*/
+                                       image->comps[0].data[index]   = (       dat8[i+0]<<4 )                          |(dat8[i+1]>>4);
+                                       image->comps[1].data[index]   = ((dat8[i+1]& 0x0f)<< 8) | dat8[i+2];
+                                       image->comps[2].data[index]   = ( dat8[i+3]<<4)                                 |(dat8[i+4]>>4);
+                                       image->comps[0].data[index+1] = ((dat8[i+4]& 0x0f)<< 8) | dat8[i+5];
+                                       image->comps[1].data[index+1] = ( dat8[i+6] <<4)                                |(dat8[i+7]>>4);
+                                       image->comps[2].data[index+1] = ((dat8[i+7]& 0x0f)<< 8) | dat8[i+8];
+                                       index+=2;
+                               }
+                       }
+                       else if( Info.tiBps==16){
+                               for (i=0; i<ssize; i+=6) {      /* 16 bits per pixel */
+                                       image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0];   // R 
+                                       image->comps[1].data[index] = ( dat8[i+3] << 8 ) | dat8[i+2];   // G 
+                                       image->comps[2].data[index] = ( dat8[i+5] << 8 ) | dat8[i+4];   // B 
+                                       index++;
+                               }
+                       }
+                       else if ( Info.tiBps==8){
+                               for (i=0; i<ssize; i+=3) {      /* 8 bits per pixel */
+                                       image->comps[0].data[index] = dat8[i+0];        // R 
+                                       image->comps[1].data[index] = dat8[i+1];        // G 
+                                       image->comps[2].data[index] = dat8[i+2];        // B 
+                                       index++;
+                               }
+                       }
+                       else{
+                               fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
+                               fprintf(stderr,"Aborting\n");
+                               return NULL;
+                       }
+               }
+
+               _TIFFfree(buf);
+               TIFFClose(tif);
+       }else if(Info.tiPhoto == 1) { 
+               /* -->> -->> -->>    
+               Black and White
+               <<-- <<-- <<-- */
+
+               numcomps = 1;
+               color_space = CLRSPC_GRAY;
+               /* initialize image components*/ 
+               memset(&cmptparm[0], 0, sizeof(opj_image_cmptparm_t));
+               cmptparm[0].prec = Info.tiBps;
+               cmptparm[0].bpp = Info.tiBps;
+               cmptparm[0].sgnd = 0;
+               cmptparm[0].dx = subsampling_dx;
+               cmptparm[0].dy = subsampling_dy;
+               cmptparm[0].w = w;
+               cmptparm[0].h = h;
+
+               /* create the image*/ 
+               image = opj_image_create(numcomps, &cmptparm[0], color_space);
+               if(!image) {
+                       TIFFClose(tif);
+                       return NULL;
+               }
+               /* set image offset and reference grid */
+               image->x0 = parameters->image_offset_x0;
+               image->y0 = parameters->image_offset_y0;
+               image->x1 =     !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
+               image->y1 =     !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
+
+               buf = _TIFFmalloc(TIFFStripSize(tif));
+               strip_size = 0;
+               strip_size = TIFFStripSize(tif);
+               index = 0;
+               /* Read the Image components*/
+               for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
+                       unsigned char *dat8;
+                       int i, ssize;
+                       ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
+                       dat8 = buf;
+
+                       if (Info.tiBps==12){
+                               for (i=0; i<ssize; i+=3) {      /* 12 bits per pixel*/
+                                       image->comps[0].data[index] = ( dat8[i+0]<<4 )                          |(dat8[i+1]>>4) ;
+                                       image->comps[0].data[index] = ((dat8[i+1]& 0x0f)<< 8)   | dat8[i+2];
+                                       index+=2;
+                               }
+                       }
+                       else if( Info.tiBps==16){
+                               for (i=0; i<ssize; i+=2) {      /* 16 bits per pixel */
+                                       image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0];
+                                       index++;
+                               }
+                       }
+                       else if ( Info.tiBps==8){
+                               for (i=0; i<ssize; i+=1) {      /* 8 bits per pixel */
+                                       image->comps[0].data[index] = dat8[i+0];
+                                       index++;
+                               }
+                       }
+                       else{
+                               fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
+                               fprintf(stderr,"Aborting\n");
+                               return NULL;
+                       }
+               }
+
+               _TIFFfree(buf);
+               TIFFClose(tif);
+       }else{
+               fprintf(stderr,"False color format. Only RGB & Grayscale has been implemented\n");
+               fprintf(stderr,"Aborting\n");
+               return NULL;
+       }
+       return image;
+}
index 95c3b3573ea57d0c96847f06b193f17c5f4a9a08..68aed4b3b434289ab0a2d27ea2a78db8aabebbbc 100644 (file)
@@ -35,6 +35,9 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
 
 int imagetobmp(opj_image_t *image, const char *outfile);
 
+/* TIFF to image conversion*/
+opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
+int imagetotif(opj_image_t *image, const char *outfile);
 /**
 Load a single image component encoded in PGX file format
 @param filename Name of the PGX file to load
index 71e3dd6a0f28eb6189c74b2d05834e293c7e5796..28208c5cd93ba8e1423ba810836393af99276248 100644 (file)
@@ -52,6 +52,7 @@
 #define PGX_DFMT 11
 #define BMP_DFMT 12
 #define YUV_DFMT 13
+#define TIF_DFMT 14
 
 /* ----------------------------------------------------------------------- */
 
@@ -356,10 +357,10 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
 int get_file_format(char *filename) {
        unsigned int i;
        static const char *extension[] = {
-    "pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2"
+    "pgx", "pnm", "pgm", "ppm", "bmp","tif", "j2k", "jp2"
     };
        static const int format[] = {
-    PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT
+    PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT,TIF_DFMT, J2K_CFMT, JP2_CFMT
     };
        char * ext = strrchr(filename, '.');
        if (ext == NULL)
@@ -443,11 +444,12 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
                                        case PGX_DFMT:
                                        case PXM_DFMT:
                                        case BMP_DFMT:
+                                       case TIF_DFMT:
                                                break;
                                        default:
                                                fprintf(stderr,
                                                        "!! Unrecognized format for infile : %s "
-              "[accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n", 
+              "[accept only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp or *.tif] !!\n\n", 
                                                        infile);
                                                return 1;
                                }
@@ -1145,8 +1147,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
        }
 
        /* check for possible errors */
-       if(img_fol->set_imgdir==1){
-               if(!(parameters->infile[0]==0)){
+       if(img_fol->set_imgdir == 1){
+               if(!(parameters->infile[0] == 0)){
                        fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
                        return 1;
                }
@@ -1234,7 +1236,6 @@ int main(int argc, char **argv) {
        opj_image_t *image = NULL;
        int i,num_images;
        int imageno;
-       char process_file = 1;
        dircnt_t *dirptr;
 
        /*
@@ -1319,7 +1320,9 @@ int main(int argc, char **argv) {
                                break;
                        case BMP_DFMT:
                                break;
-
+                       case TIF_DFMT:
+                               break;
+               
                        default:
                                fprintf(stderr,"skipping file...\n");
                                continue;                       
@@ -1332,15 +1335,15 @@ int main(int argc, char **argv) {
                                case PGX_DFMT:
                                        image = pgxtoimage(parameters.infile, &parameters);
                                        if (!image) {
-                                               fprintf(stderr, " unable to load pgx file\n");
-                                               return 1;
+                                               fprintf(stderr, "Unable to load pgx file\n");
+                                               return 1; 
                                        }
                                        break;
 
                                case PXM_DFMT:
                                        image = pnmtoimage(parameters.infile, &parameters);
                                        if (!image) {
-                                               fprintf(stderr, " not a pnm file\n");
+                                               fprintf(stderr, "Unable to load pnm file\n");
                                                return 1;
                                        }
                                        break;
@@ -1348,11 +1351,19 @@ int main(int argc, char **argv) {
                                case BMP_DFMT:
                                        image = bmptoimage(parameters.infile, &parameters);
                                        if (!image) {
-                                               fprintf(stderr, " not a bmp file\n");
+                                               fprintf(stderr, "Unable to load bmp file\n");
                                                return 1;
                                        }
                                        break;
-                       }
+                       
+                               case TIF_DFMT:
+                                       image = tiftoimage(parameters.infile, &parameters);
+                                       if (!image) {
+                                               fprintf(stderr, "Unable to load tiff file\n");
+                                               return 1;
+                                       }
+                               break;
+               }
 
                        /* encode the destination image */
                        /* ---------------------------- */
index 91651de96a5410c248f7efabbaa51b833361c8be..223f44eec1eac6c150c3005953c73332bd582b5c 100644 (file)
@@ -52,6 +52,7 @@
 #define PGX_DFMT 11
 #define BMP_DFMT 12
 #define YUV_DFMT 13
+#define TIF_DFMT 14
 
 /* ----------------------------------------------------------------------- */
 
@@ -179,8 +180,8 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
 
 int get_file_format(char *filename) {
        unsigned int i;
-       static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2", "jpt" };
-       static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
+       static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "j2k", "jp2", "jpt" };
+       static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
        char * ext = strrchr(filename, '.');
        if (ext == NULL)
                return -1;
@@ -200,7 +201,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
        char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
 
        strcpy(image_filename,dirptr->filename[imageno]);
-       fprintf(stderr,"Imageno=%d %s\n",imageno,image_filename);
+       fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
        parameters->decod_format = get_file_format(image_filename);
        if (parameters->decod_format == -1)
                return 1;
@@ -271,6 +272,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
                                        case PGX_DFMT:
                                        case PXM_DFMT:
                                        case BMP_DFMT:
+                                       case TIF_DFMT:
                                                break;
                                        default:
                                                fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n", outfile);
@@ -299,6 +301,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
                                        case BMP_DFMT:
                                                img_fol->out_format = "bmp";
                                                break;
+                                       case TIF_DFMT:
+                                               img_fol->out_format = "tif";
+                                               break;
                                        default:
                                                fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n");
                                                return 1;
@@ -484,7 +489,6 @@ int main(int argc, char **argv) {
        int num_images;
        int i,imageno;
        dircnt_t *dirptr;
-       char process_file = 1;
        opj_dinfo_t* dinfo = NULL;      /* handle to a decompressor */
        opj_cio_t *cio = NULL;
 
@@ -657,7 +661,7 @@ int main(int argc, char **argv) {
                break;
 
                default:
-                       fprintf(stderr, "False input image format skipping file..\n");
+                       fprintf(stderr, "skipping file..\n");
                        continue;
        }
 
@@ -667,26 +671,50 @@ int main(int argc, char **argv) {
 
                /* create output image */
                /* ------------------- */
-                       switch (parameters.cod_format) {
+               switch (parameters.cod_format) {
                case PXM_DFMT:                  /* PNM PGM PPM */
-                       imagetopnm(image, parameters.outfile);
+                       if (imagetopnm(image, parameters.outfile)) {
+                               fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+                       }
+                       else {
+                               fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+                       }
                        break;
 
                case PGX_DFMT:                  /* PGX */
-                       imagetopgx(image, parameters.outfile);
+                       if(imagetopgx(image, parameters.outfile)){
+                               fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+                       }
+                       else {
+                               fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+                       }
                        break;
 
                case BMP_DFMT:                  /* BMP */
-                       imagetobmp(image, parameters.outfile);
-                       break;
+                       if(imagetobmp(image, parameters.outfile)){
+                               fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+                       }
+                       else {
+                               fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
                        }
+                       break;
 
-                       /* free remaining structures */
-                       if(dinfo) {
-                               opj_destroy_decompress(dinfo);
+               case TIF_DFMT:                  /* TIFF */
+                       if(imagetotif(image, parameters.outfile)){
+                               fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
                        }
-                       /* free image data structure */
-                       opj_image_destroy(image);
+                       else {
+                               fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+                       }
+                       break;
+               }
+
+               /* free remaining structures */
+               if(dinfo) {
+                       opj_destroy_decompress(dinfo);
+               }
+               /* free image data structure */
+               opj_image_destroy(image);
 
        }
        return 0;
index 6b52913882c81e589d0691e062c08941878f61c2..ceb5df2cd43fed142eb03e6cd9069c100da5b49a 100644 (file)
@@ -277,7 +277,7 @@ typedef struct opj_cparameters {
        int subsampling_dx;
        /** subsampling value for dy */
        int subsampling_dy;
-       /** input file format 0: PGX, 1: PxM, 2: BMP */
+       /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
        int decod_format;
        /** output file format 0: J2K, 1: JP2, 2: JPT */
        int cod_format;
diff --git a/libs/libtiff/Tiffcomp.h b/libs/libtiff/Tiffcomp.h
new file mode 100644 (file)
index 0000000..516e638
--- /dev/null
@@ -0,0 +1,214 @@
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.49 1996/04/29 21:56:21 sam Rel $ */
+
+/*
+ * Copyright (c) 1990-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _COMPAT_
+#define        _COMPAT_
+/*
+ * This file contains a hodgepodge of definitions and
+ * declarations that are needed to provide compatibility
+ * between the native system and the base implementation
+ * that the library assumes.
+ *
+ * NB: This file is a mess.
+ */
+
+/*
+ * Setup basic type definitions and function declaratations.
+ */
+
+/*
+ * Simplify Acorn RISC OS identifier (to avoid confusion with Acorn RISC iX
+ * and with defunct Unix Risc OS)
+ * No need to specify __arm - hey, Acorn might port the OS, no problem here!
+ */
+#ifdef __acornriscos
+#undef __acornriscos
+#endif
+#if defined(__acorn) && defined(__riscos)
+#define __acornriscos
+#endif
+
+#if defined(__MWERKS__) || defined(THINK_C)
+#include <unix.h>
+#include <math.h>
+#endif
+
+#include <stdio.h>
+
+#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__)
+#include <types.h>
+#elif !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acornriscos) && !defined(applec)
+#include <sys/types.h>
+#endif
+
+#if defined(VMS)
+#include <file.h>
+#include <unixio.h>
+#elif !defined(__acornriscos)
+#include <fcntl.h>
+#endif
+
+/*
+ * This maze of checks controls defines or not the
+ * target system has BSD-style typdedefs declared in
+ * an include file and/or whether or not to include
+ * <unistd.h> to get the SEEK_* definitions.  Some
+ * additional includes are also done to pull in the
+ * appropriate definitions we're looking for.
+ */
+#if defined(__MWERKS__) || defined(THINK_C) || defined(__PPCC__) || defined(__SC__) || defined(__MRC__)
+#include <stdlib.h>
+#define        BSDTYPES
+#define        HAVE_UNISTD_H   0
+#elif defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
+#define        BSDTYPES
+#elif defined(OS2_16) || defined(OS2_32)
+#define        BSDTYPES
+#elif defined(__acornriscos)
+#include <stdlib.h>
+#define        BSDTYPES
+#define        HAVE_UNISTD_H   0
+#elif defined(VMS)
+#define        HAVE_UNISTD_H   0
+#else
+#define        HAVE_UNISTD_H   1
+#endif
+
+/*
+ * The library uses the ANSI C/POSIX SEEK_*
+ * definitions that should be defined in unistd.h
+ * (except on system where they are in stdio.h and
+ * there is no unistd.h).
+ */
+#if !defined(SEEK_SET) && HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/*
+ * The library uses memset, memcpy, and memcmp.
+ * ANSI C and System V define these in string.h.
+ */
+#include <string.h>
+
+/*
+ * The BSD typedefs are used throughout the library.
+ * If your system doesn't have them in <sys/types.h>,
+ * then define BSDTYPES in your Makefile.
+ */
+#if defined(BSDTYPES)
+typedef        unsigned char u_char;
+typedef        unsigned short u_short;
+typedef        unsigned int u_int;
+typedef        unsigned long u_long;
+#endif
+
+/*
+ * dblparam_t is the type that a double precision
+ * floating point value will have on the parameter
+ * stack (when coerced by the compiler).
+ */
+/* Note: on MacPowerPC "extended" is undefined. So only use it for 68K-Macs */
+#if defined(__SC__) || defined(THINK_C)
+typedef extended dblparam_t;
+#else
+typedef double dblparam_t;
+#endif
+
+/*
+ * If your compiler supports inline functions, then
+ * set INLINE appropriately to get the known hotspots
+ * in the library expanded inline.
+ */
+#if defined(__GNUC__)
+#if defined(__STRICT_ANSI__)
+#define        INLINE  __inline__
+#else
+#define        INLINE  inline
+#endif
+#else /* !__GNUC__ */
+#define        INLINE
+#endif
+
+/*
+ * GLOBALDATA is a macro that is used to define global variables
+ * private to the library.  We use this indirection to hide
+ * brain-damage in VAXC (and GCC) under VAX/VMS.  In these
+ * environments the macro places the variable in a non-shareable
+ * program section, which ought to be done by default (sigh!)
+ *
+ * Apparently DEC are aware of the problem as this behaviour is the
+ * default under VMS on AXP.
+ *
+ * The GNU C variant is untested.
+ */
+#if defined(VAX) && defined(VMS)
+#if defined(VAXC)
+#define GLOBALDATA(TYPE,NAME)  extern noshare TYPE NAME
+#endif
+#if defined(__GNUC__)
+#define GLOBALDATA(TYPE,NAME)  extern TYPE NAME \
+       asm("_$$PsectAttributes_NOSHR$$" #NAME)
+#endif
+#else  /* !VAX/VMS */
+#define GLOBALDATA(TYPE,NAME)  extern TYPE NAME
+#endif
+
+#if defined(__acornriscos)
+/*
+ * osfcn.h is part of C++Lib on Acorn C/C++, and as such can't be used
+ * on C alone. For that reason, the relevant functions are
+ * implemented in tif_acorn.c, and the elements from the header
+ * file are included here.
+ */
+#if defined(__cplusplus)
+#include <osfcn.h>
+#else
+#define        O_RDONLY        0
+#define        O_WRONLY        1
+#define        O_RDWR          2
+#define        O_APPEND        8
+#define        O_CREAT         0x200
+#define        O_TRUNC         0x400
+typedef long off_t;
+extern int open(const char *name, int flags, int mode);
+extern int close(int fd);
+extern int write(int fd, const char *buf, int nbytes);
+extern int read(int fd, char *buf, int nbytes);
+extern off_t lseek(int fd, off_t offset, int whence);
+extern int creat(const char *path, int mode);
+#endif /* __cplusplus */
+#endif /* __acornriscos */
+
+/* Bit and byte order, the default is MSB to LSB */
+#ifdef VMS
+#undef HOST_FILLORDER
+#undef HOST_BIGENDIAN
+#define HOST_FILLORDER FILLORDER_LSB2MSB
+#define HOST_BIGENDIAN 0
+#endif
+
+
+#endif /* _COMPAT_ */
diff --git a/libs/libtiff/Tiffconf.h b/libs/libtiff/Tiffconf.h
new file mode 100644 (file)
index 0000000..c121550
--- /dev/null
@@ -0,0 +1,131 @@
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffconf.h,v 1.13 1996/04/05 17:36:53 sam Rel $ */\r
+/*\r
+ * Copyright (c) 1988-1996 Sam Leffler\r
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.\r
+ *\r
+ * Permission to use, copy, modify, distribute, and sell this software and \r
+ * its documentation for any purpose is hereby granted without fee, provided\r
+ * that (i) the above copyright notices and this permission notice appear in\r
+ * all copies of the software and related documentation, and (ii) the names of\r
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or\r
+ * publicity relating to the software without the specific, prior written\r
+ * permission of Sam Leffler and Silicon Graphics.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, \r
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY \r
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  \r
+ * \r
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR\r
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,\r
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\r
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF \r
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE \r
+ * OF THIS SOFTWARE.\r
+ */\r
+\r
+#ifndef _TIFFCONF_\r
+#define        _TIFFCONF_\r
+/*\r
+ * Library Configuration Definitions.\r
+ *\r
+ * This file defines the default configuration for the library.\r
+ * If the target system does not have make or a way to specify\r
+ * #defines on the command line, this file can be edited to\r
+ * configure the library.  Otherwise, one can override portability\r
+ * and configuration-related definitions from a Makefile or command\r
+ * line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below).\r
+ */\r
+\r
+/*\r
+ * General portability-related defines:\r
+ *\r
+ * HAVE_IEEEFP         define as 0 or 1 according to the floating point\r
+ *                     format suported by the machine\r
+ * BSDTYPES            define this if your system does NOT define the\r
+ *                     usual 4BSD typedefs u_int et. al.\r
+ * HAVE_MMAP           enable support for memory mapping read-only files;\r
+ *                     this is typically deduced by the configure script\r
+ * HOST_FILLORDER      native cpu bit order: one of FILLORDER_MSB2LSB\r
+ *                     or FILLODER_LSB2MSB; this is typically set by the\r
+ *                     configure script\r
+ * HOST_BIGENDIAN      native cpu byte order: 1 if big-endian (Motorola)\r
+ *                     or 0 if little-endian (Intel); this may be used\r
+ *                     in codecs to optimize code\r
+ */\r
+#ifndef HAVE_IEEEFP\r
+#define        HAVE_IEEEFP     1\r
+#endif\r
+#ifndef HOST_FILLORDER\r
+#define        HOST_FILLORDER  FILLORDER_MSB2LSB\r
+#endif\r
+#ifndef        HOST_BIGENDIAN\r
+#define        HOST_BIGENDIAN  1\r
+#endif\r
+\r
+#ifndef FEATURE_SUPPORT\r
+/*\r
+ * Feature support definitions:\r
+ *\r
+ *    COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags\r
+ *    YCBCR_SUPPORT    enable support for 6.0 YCbCr tags\r
+ *    CMYK_SUPPORT     enable support for 6.0 CMYK tags\r
+ */\r
+#define        COLORIMETRY_SUPPORT\r
+#define        YCBCR_SUPPORT\r
+#define        CMYK_SUPPORT\r
+#endif /* FEATURE_SUPPORT */\r
+\r
+#ifndef COMPRESSION_SUPPORT\r
+/*\r
+ * Compression support defines:\r
+ *\r
+ *    CCITT_SUPPORT    enable support for CCITT Group 3 & 4 algorithms\r
+ *    PACKBITS_SUPPORT enable support for Macintosh PackBits algorithm\r
+ *    LZW_SUPPORT      enable support for LZW algorithm\r
+ *    THUNDER_SUPPORT  enable support for ThunderScan 4-bit RLE algorithm\r
+ *    NEXT_SUPPORT     enable support for NeXT 2-bit RLE algorithm\r
+ *    OJPEG_SUPPORT    enable support for 6.0-style JPEG DCT algorithms\r
+ *                     (no builtin support, only a codec hook)\r
+ *    JPEG_SUPPORT     enable support for post-6.0-style JPEG DCT algorithms\r
+ *                     (requires freely available IJG software, see tif_jpeg.c)\r
+ *    ZIP_SUPPORT      enable support for Deflate algorithm\r
+ *                     (requires freely available zlib software, see tif_zip.c)\r
+ *    PIXARLOG_SUPPORT enable support for Pixar log-format algorithm\r
+ */\r
+/* doesn't work with Windows makefile??? */\r
+#if 0\r
+#define        CCITT_SUPPORT\r
+#endif\r
+#define        PACKBITS_SUPPORT\r
+#define        LZW_SUPPORT\r
+#define        THUNDER_SUPPORT\r
+#define        NEXT_SUPPORT\r
+#endif /* COMPRESSION_SUPPORT */\r
+\r
+/*\r
+ * If JPEG compression is enabled then we must also include\r
+ * support for the colorimetry and YCbCr-related tags.\r
+ */\r
+#ifdef JPEG_SUPPORT\r
+#ifndef YCBCR_SUPPORT\r
+#define        YCBCR_SUPPORT\r
+#endif\r
+#ifndef COLORIMETRY_SUPPORT\r
+#define        COLORIMETRY_SUPPORT\r
+#endif\r
+#endif /* JPEG_SUPPORT */\r
+\r
+/*\r
+ * ``Orthogonal Features''\r
+ *\r
+ * STRIPCHOP_SUPPORT   automatically convert single-strip uncompressed images\r
+ *                     to mutiple strips of ~8Kb (for reducing memory use)\r
+ * SUBIFD_SUPPORT      enable support for SubIFD tag (thumbnails and such)\r
+ */\r
+#ifndef STRIPCHOP_SUPPORT\r
+#define        STRIPCHOP_SUPPORT       1       /* enable strip chopping */\r
+#endif\r
+#ifndef SUBIFD_SUPPORT\r
+#define        SUBIFD_SUPPORT          1       /* enable SubIFD tag (330) support */\r
+#endif\r
+#endif /* _TIFFCONF_ */\r
diff --git a/libs/libtiff/Tiffiop.h b/libs/libtiff/Tiffiop.h
new file mode 100644 (file)
index 0000000..e4ffc59
--- /dev/null
@@ -0,0 +1,287 @@
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffiop.h,v 1.80 1996/04/05 17:36:53 sam Rel $ */
+
+/*
+ * Copyright (c) 1988-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _TIFFIOP_
+#define        _TIFFIOP_
+/*
+ * ``Library-private'' definitions.
+ */
+/*
+ * UNIX systems should run the configure script to generate
+ * a port.h file that reflects the system capabilities.
+ * Doing this obviates all the dreck done in tiffcomp.h.
+ */
+#if defined(unix) || defined(__unix)
+#include "port.h"
+#include "tiffconf.h"
+#else
+#include "tiffconf.h"
+#include "tiffcomp.h"
+#endif
+#include "tiffio.h"
+#include "tif_dir.h"
+
+#ifndef TRUE
+#define        TRUE    1
+#define        FALSE   0
+#endif
+
+/*
+ * Typedefs for ``method pointers'' used internally.
+ */
+typedef        unsigned char tidataval_t;      /* internal image data value type */
+typedef        tidataval_t* tidata_t;          /* reference to internal image data */
+
+typedef        void (*TIFFVoidMethod)(TIFF*);
+typedef        int (*TIFFBoolMethod)(TIFF*);
+typedef        int (*TIFFPreMethod)(TIFF*, tsample_t);
+typedef        int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t);
+typedef        int (*TIFFSeekMethod)(TIFF*, uint32);
+typedef        void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t);
+typedef        int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list);
+typedef        int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list);
+typedef        void (*TIFFPrintMethod)(TIFF*, FILE*, long);
+typedef        uint32 (*TIFFStripMethod)(TIFF*, uint32);
+typedef        void (*TIFFTileMethod)(TIFF*, uint32*, uint32*);
+
+struct tiff {
+       char*           tif_name;       /* name of open file */
+       int             tif_fd;         /* open file descriptor */
+       int             tif_mode;       /* open mode (O_*) */
+       uint32          tif_flags;
+#define        TIFF_FILLORDER          0x0003  /* natural bit fill order for machine */
+#define        TIFF_DIRTYHEADER        0x0004  /* header must be written on close */
+#define        TIFF_DIRTYDIRECT        0x0008  /* current directory must be written */
+#define        TIFF_BUFFERSETUP        0x0010  /* data buffers setup */
+#define        TIFF_CODERSETUP         0x0020  /* encoder/decoder setup done */
+#define        TIFF_BEENWRITING        0x0040  /* written 1+ scanlines to file */
+#define        TIFF_SWAB               0x0080  /* byte swap file information */
+#define        TIFF_NOBITREV           0x0100  /* inhibit bit reversal logic */
+#define        TIFF_MYBUFFER           0x0200  /* my raw data buffer; free on close */
+#define        TIFF_ISTILED            0x0400  /* file is tile, not strip- based */
+#define        TIFF_MAPPED             0x0800  /* file is mapped into memory */
+#define        TIFF_POSTENCODE         0x1000  /* need call to postencode routine */
+#define        TIFF_INSUBIFD           0x2000  /* currently writing a subifd */
+#define        TIFF_UPSAMPLED          0x4000  /* library is doing data up-sampling */ 
+#define        TIFF_STRIPCHOP          0x8000  /* enable strip chopping support */
+       toff_t          tif_diroff;     /* file offset of current directory */
+       toff_t          tif_nextdiroff; /* file offset of following directory */
+       TIFFDirectory   tif_dir;        /* internal rep of current directory */
+       TIFFHeader      tif_header;     /* file's header block */
+        tidata_t        tif_clientdir;  /* client TIFF directory */
+       const int*      tif_typeshift;  /* data type shift counts */
+       const long*     tif_typemask;   /* data type masks */
+       uint32          tif_row;        /* current scanline */
+       tdir_t          tif_curdir;     /* current directory (index) */
+       tstrip_t        tif_curstrip;   /* current strip for read/write */
+       toff_t          tif_curoff;     /* current offset for read/write */
+       toff_t          tif_dataoff;    /* current offset for writing dir */
+#if SUBIFD_SUPPORT
+       uint16          tif_nsubifd;    /* remaining subifds to write */
+       toff_t          tif_subifdoff;  /* offset for patching SubIFD link */
+#endif
+/* tiling support */
+       uint32          tif_col;        /* current column (offset by row too) */
+       ttile_t         tif_curtile;    /* current tile for read/write */
+       tsize_t         tif_tilesize;   /* # of bytes in a tile */
+/* compression scheme hooks */
+       TIFFBoolMethod  tif_setupdecode;/* called once before predecode */
+       TIFFPreMethod   tif_predecode;  /* pre- row/strip/tile decoding */
+       TIFFBoolMethod  tif_setupencode;/* called once before preencode */
+       TIFFPreMethod   tif_preencode;  /* pre- row/strip/tile encoding */
+       TIFFBoolMethod  tif_postencode; /* post- row/strip/tile encoding */
+       TIFFCodeMethod  tif_decoderow;  /* scanline decoding routine */
+       TIFFCodeMethod  tif_encoderow;  /* scanline encoding routine */
+       TIFFCodeMethod  tif_decodestrip;/* strip decoding routine */
+       TIFFCodeMethod  tif_encodestrip;/* strip encoding routine */
+       TIFFCodeMethod  tif_decodetile; /* tile decoding routine */
+       TIFFCodeMethod  tif_encodetile; /* tile encoding routine */
+       TIFFVoidMethod  tif_close;      /* cleanup-on-close routine */
+       TIFFSeekMethod  tif_seek;       /* position within a strip routine */
+       TIFFVoidMethod  tif_cleanup;    /* cleanup state routine */
+       TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */
+       TIFFTileMethod  tif_deftilesize;/* calculate/constrain tile size */
+       tidata_t        tif_data;       /* compression scheme private data */
+/* input/output buffering */
+       tsize_t         tif_scanlinesize;/* # of bytes in a scanline */
+       tsize_t         tif_scanlineskew;/* scanline skew for reading strips */
+       tidata_t        tif_rawdata;    /* raw data buffer */
+       tsize_t         tif_rawdatasize;/* # of bytes in raw data buffer */
+       tidata_t        tif_rawcp;      /* current spot in raw buffer */
+       tsize_t         tif_rawcc;      /* bytes unread from raw buffer */
+/* memory-mapped file support */
+       tidata_t        tif_base;       /* base of mapped file */
+#ifdef __WIN32__
+       void*           pv_map_handle;  /* WIN32 file mapping handle;
+                                        * must be contiguous with tif_base
+                                        * since map & unmap only get tif_base
+                                        * and assume 4 byte offset to
+                                        * pv_map_handle. */
+#endif
+       toff_t          tif_size;       /* size of mapped file region (bytes) */
+       TIFFMapFileProc tif_mapproc;    /* map file method */
+       TIFFUnmapFileProc tif_unmapproc;/* unmap file method */
+/* input/output callback methods */
+       thandle_t       tif_clientdata; /* callback parameter */
+       TIFFReadWriteProc tif_readproc; /* read method */
+       TIFFReadWriteProc tif_writeproc;/* write method */
+       TIFFSeekProc    tif_seekproc;   /* lseek method */
+       TIFFCloseProc   tif_closeproc;  /* close method */
+       TIFFSizeProc    tif_sizeproc;   /* filesize method */
+/* post-decoding support */
+       TIFFPostMethod  tif_postdecode; /* post decoding routine */
+/* tag support */
+       TIFFFieldInfo** tif_fieldinfo;  /* sorted table of registered tags */
+       int             tif_nfields;    /* # entries in registered tag table */
+       TIFFVSetMethod  tif_vsetfield;  /* tag set routine */
+       TIFFVGetMethod  tif_vgetfield;  /* tag get routine */
+       TIFFPrintMethod tif_printdir;   /* directory print routine */
+};
+
+#define        isPseudoTag(t)  (t > 0xffff)    /* is tag value normal or pseudo */
+
+#define        isTiled(tif)    (((tif)->tif_flags & TIFF_ISTILED) != 0)
+#define        isMapped(tif)   (((tif)->tif_flags & TIFF_MAPPED) != 0)
+#define        isFillOrder(tif, o)     (((tif)->tif_flags & (o)) != 0)
+#define        isUpSampled(tif)        (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
+#define        TIFFReadFile(tif, buf, size) \
+       ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size))
+#define        TIFFWriteFile(tif, buf, size) \
+       ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size))
+#define        TIFFSeekFile(tif, off, whence) \
+       ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence))
+#define        TIFFCloseFile(tif) \
+       ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
+#define        TIFFGetFileSize(tif) \
+       ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
+#define        TIFFMapFileContents(tif, paddr, psize) \
+       ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize))
+#ifdef __WIN32__
+#define        TIFFUnmapFileContents(tif, addr, dummy) \
+       ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,\
+           (toff_t)(tif)->pv_map_handle))
+#else
+#define        TIFFUnmapFileContents(tif, addr, size) \
+       ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size))
+#endif
+
+/*
+ * Default Read/Seek/Write definitions.
+ */
+#ifndef ReadOK
+#define        ReadOK(tif, buf, size) \
+       (TIFFReadFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size)
+#endif
+#ifndef SeekOK
+#define        SeekOK(tif, off) \
+       (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off)
+#endif
+#ifndef WriteOK
+#define        WriteOK(tif, buf, size) \
+       (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size)
+#endif
+
+/* NB: the uint32 casts are to silence certain ANSI-C compilers */
+#define        TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y)))
+#define        TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y)))
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+extern int _TIFFgetMode(const char*, const char*);
+extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t);
+extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t);
+extern int _TIFFNoSeek(TIFF*, uint32);
+extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t);
+extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t);
+extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t);
+extern int TIFFFlushData1(TIFF*);
+extern void TIFFFreeDirectory(TIFF*);
+extern int TIFFDefaultDirectory(TIFF*);
+extern int TIFFSetCompressionScheme(TIFF*, int);
+extern uint32 _TIFFDefaultStripSize(TIFF*, uint32);
+extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
+
+extern void _TIFFsetByteArray(void**, void*, long);
+extern void _TIFFsetString(char**, char*);
+extern void _TIFFsetShortArray(uint16**, uint16*, long);
+extern void _TIFFsetLongArray(uint32**, uint32*, long);
+extern void _TIFFsetFloatArray(float**, float*, long);
+extern void _TIFFsetDoubleArray(double**, double*, long);
+
+extern void _TIFFprintAscii(FILE*, const char*);
+extern void _TIFFprintAsciiTag(FILE*, const char*, const char*);
+
+GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler);
+GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler);
+
+extern int TIFFInitDumpMode(TIFF*, int);
+#ifdef PACKBITS_SUPPORT
+extern int TIFFInitPackBits(TIFF*, int);
+#endif
+#ifdef CCITT_SUPPORT
+extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int);
+extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int);
+#endif
+#ifdef THUNDER_SUPPORT
+extern int TIFFInitThunderScan(TIFF*, int);
+#endif
+#ifdef NEXT_SUPPORT
+extern int TIFFInitNeXT(TIFF*, int);
+#endif
+#ifdef LZW_SUPPORT
+extern int TIFFInitLZW(TIFF*, int);
+#endif
+#ifdef OJPEG_SUPPORT
+extern int TIFFInitOJPEG(TIFF*, int);
+#endif
+#ifdef JPEG_SUPPORT
+extern int TIFFInitJPEG(TIFF*, int);
+#endif
+#ifdef JBIG_SUPPORT
+extern int TIFFInitJBIG(TIFF*, int);
+#endif
+#ifdef ZIP_SUPPORT
+extern int TIFFInitZIP(TIFF*, int);
+#endif
+#ifdef PIXARLOG_SUPPORT
+extern int TIFFInitPixarLog(TIFF*, int);
+#endif
+#ifdef VMS
+extern const TIFFCodec _TIFFBuiltinCODECS[];
+#else
+extern TIFFCodec _TIFFBuiltinCODECS[];
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+#endif /* _TIFFIOP_ */
diff --git a/libs/libtiff/Version.h b/libs/libtiff/Version.h
new file mode 100644 (file)
index 0000000..11b9435
--- /dev/null
@@ -0,0 +1 @@
+#define VERSION "LIBTIFF, Version 3.4beta024\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."\r
diff --git a/libs/libtiff/libtiff.lib b/libs/libtiff/libtiff.lib
new file mode 100644 (file)
index 0000000..224b1e8
Binary files /dev/null and b/libs/libtiff/libtiff.lib differ
diff --git a/libs/libtiff/tiff.h b/libs/libtiff/tiff.h
new file mode 100644 (file)
index 0000000..d6e146e
--- /dev/null
@@ -0,0 +1,380 @@
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiff.h,v 1.71 1996/04/29 22:16:05 sam Rel $ */
+
+/*
+ * Copyright (c) 1988-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _TIFF_
+#define        _TIFF_
+/*
+ * Tag Image File Format (TIFF)
+ *
+ * Based on Rev 6.0 from:
+ *    Developer's Desk
+ *    Aldus Corporation
+ *    411 First Ave. South
+ *    Suite 200
+ *    Seattle, WA  98104
+ *    206-622-5500
+ */
+#define        TIFF_VERSION    42
+
+#define        TIFF_BIGENDIAN          0x4d4d
+#define        TIFF_LITTLEENDIAN       0x4949
+
+#ifndef _TIFF_DATA_TYPEDEFS_
+#define _TIFF_DATA_TYPEDEFS_
+/*
+ * Intrinsic data types required by the file format:
+ *
+ * 8-bit quantities    int8/uint8
+ * 16-bit quantities   int16/uint16
+ * 32-bit quantities   int32/uint32
+ * strings             unsigned char*
+ */
+#ifdef __STDC__
+typedef        signed char int8;       /* NB: non-ANSI compilers may not grok */
+#else
+typedef        char int8;
+#endif
+typedef        unsigned char uint8;
+typedef        short int16;
+typedef        unsigned short uint16;  /* sizeof (uint16) must == 2 */
+#if defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64)
+typedef        int int32;
+typedef        unsigned int uint32;    /* sizeof (uint32) must == 4 */
+#else
+typedef        long int32;
+typedef        unsigned long uint32;   /* sizeof (uint32) must == 4 */
+#endif
+#endif /* _TIFF_DATA_TYPEDEFS_ */
+
+typedef        struct {
+       uint16  tiff_magic;     /* magic number (defines byte order) */
+       uint16  tiff_version;   /* TIFF version number */
+       uint32  tiff_diroff;    /* byte offset to first directory */
+} TIFFHeader;
+
+/*
+ * TIFF Image File Directories are comprised of
+ * a table of field descriptors of the form shown
+ * below.  The table is sorted in ascending order
+ * by tag.  The values associated with each entry
+ * are disjoint and may appear anywhere in the file
+ * (so long as they are placed on a word boundary).
+ *
+ * If the value is 4 bytes or less, then it is placed
+ * in the offset field to save space.  If the value
+ * is less than 4 bytes, it is left-justified in the
+ * offset field.
+ */
+typedef        struct {
+       uint16  tdir_tag;       /* see below */
+       uint16  tdir_type;      /* data type; see below */
+       uint32  tdir_count;     /* number of items; length in spec */
+       uint32  tdir_offset;    /* byte offset to field data */
+} TIFFDirEntry;
+
+/*
+ * NB: In the comments below,
+ *  - items marked with a + are obsoleted by revision 5.0,
+ *  - items marked with a ! are introduced in revision 6.0.
+ *  - items marked with a % are introduced post revision 6.0.
+ *  - items marked with a $ are obsoleted by revision 6.0.
+ */
+
+/*
+ * Tag data type information.
+ *
+ * Note: RATIONALs are the ratio of two 32-bit integer values.
+ */
+typedef        enum {
+       TIFF_NOTYPE     = 0,    /* placeholder */
+       TIFF_BYTE       = 1,    /* 8-bit unsigned integer */
+       TIFF_ASCII      = 2,    /* 8-bit bytes w/ last byte null */
+       TIFF_SHORT      = 3,    /* 16-bit unsigned integer */
+       TIFF_LONG       = 4,    /* 32-bit unsigned integer */
+       TIFF_RATIONAL   = 5,    /* 64-bit unsigned fraction */
+       TIFF_SBYTE      = 6,    /* !8-bit signed integer */
+       TIFF_UNDEFINED  = 7,    /* !8-bit untyped data */
+       TIFF_SSHORT     = 8,    /* !16-bit signed integer */
+       TIFF_SLONG      = 9,    /* !32-bit signed integer */
+       TIFF_SRATIONAL  = 10,   /* !64-bit signed fraction */
+       TIFF_FLOAT      = 11,   /* !32-bit IEEE floating point */
+       TIFF_DOUBLE     = 12    /* !64-bit IEEE floating point */
+} TIFFDataType;
+
+/*
+ * TIFF Tag Definitions.
+ */
+#define        TIFFTAG_SUBFILETYPE             254     /* subfile data descriptor */
+#define            FILETYPE_REDUCEDIMAGE       0x1     /* reduced resolution version */
+#define            FILETYPE_PAGE               0x2     /* one page of many */
+#define            FILETYPE_MASK               0x4     /* transparency mask */
+#define        TIFFTAG_OSUBFILETYPE            255     /* +kind of data in subfile */
+#define            OFILETYPE_IMAGE             1       /* full resolution image data */
+#define            OFILETYPE_REDUCEDIMAGE      2       /* reduced size image data */
+#define            OFILETYPE_PAGE              3       /* one page of many */
+#define        TIFFTAG_IMAGEWIDTH              256     /* image width in pixels */
+#define        TIFFTAG_IMAGELENGTH             257     /* image height in pixels */
+#define        TIFFTAG_BITSPERSAMPLE           258     /* bits per channel (sample) */
+#define        TIFFTAG_COMPRESSION             259     /* data compression technique */
+#define            COMPRESSION_NONE            1       /* dump mode */
+#define            COMPRESSION_CCITTRLE        2       /* CCITT modified Huffman RLE */
+#define            COMPRESSION_CCITTFAX3       3       /* CCITT Group 3 fax encoding */
+#define            COMPRESSION_CCITTFAX4       4       /* CCITT Group 4 fax encoding */
+#define            COMPRESSION_LZW             5       /* Lempel-Ziv  & Welch */
+#define            COMPRESSION_OJPEG           6       /* !6.0 JPEG */
+#define            COMPRESSION_JPEG            7       /* %JPEG DCT compression */
+#define            COMPRESSION_NEXT            32766   /* NeXT 2-bit RLE */
+#define            COMPRESSION_CCITTRLEW       32771   /* #1 w/ word alignment */
+#define            COMPRESSION_PACKBITS        32773   /* Macintosh RLE */
+#define            COMPRESSION_THUNDERSCAN     32809   /* ThunderScan RLE */
+/* compression codes 32908-32911 are reserved for Pixar */
+#define     COMPRESSION_PIXARFILM      32908   /* Pixar companded 10bit LZW */
+#define            COMPRESSION_PIXARLOG        32909   /* Pixar companded 11bit ZIP */
+#define            COMPRESSION_DEFLATE         32946   /* Deflate compression */
+/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */
+#define     COMPRESSION_DCS             32947   /* Kodak DCS encoding */
+#define            COMPRESSION_JBIG            34661   /* ISO JBIG */
+#define        TIFFTAG_PHOTOMETRIC             262     /* photometric interpretation */
+#define            PHOTOMETRIC_MINISWHITE      0       /* min value is white */
+#define            PHOTOMETRIC_MINISBLACK      1       /* min value is black */
+#define            PHOTOMETRIC_RGB             2       /* RGB color model */
+#define            PHOTOMETRIC_PALETTE         3       /* color map indexed */
+#define            PHOTOMETRIC_MASK            4       /* $holdout mask */
+#define            PHOTOMETRIC_SEPARATED       5       /* !color separations */
+#define            PHOTOMETRIC_YCBCR           6       /* !CCIR 601 */
+#define            PHOTOMETRIC_CIELAB          8       /* !1976 CIE L*a*b* */
+#define        TIFFTAG_THRESHHOLDING           263     /* +thresholding used on data */
+#define            THRESHHOLD_BILEVEL          1       /* b&w art scan */
+#define            THRESHHOLD_HALFTONE         2       /* or dithered scan */
+#define            THRESHHOLD_ERRORDIFFUSE     3       /* usually floyd-steinberg */
+#define        TIFFTAG_CELLWIDTH               264     /* +dithering matrix width */
+#define        TIFFTAG_CELLLENGTH              265     /* +dithering matrix height */
+#define        TIFFTAG_FILLORDER               266     /* data order within a byte */
+#define            FILLORDER_MSB2LSB           1       /* most significant -> least */
+#define            FILLORDER_LSB2MSB           2       /* least significant -> most */
+#define        TIFFTAG_DOCUMENTNAME            269     /* name of doc. image is from */
+#define        TIFFTAG_IMAGEDESCRIPTION        270     /* info about image */
+#define        TIFFTAG_MAKE                    271     /* scanner manufacturer name */
+#define        TIFFTAG_MODEL                   272     /* scanner model name/number */
+#define        TIFFTAG_STRIPOFFSETS            273     /* offsets to data strips */
+#define        TIFFTAG_ORIENTATION             274     /* +image orientation */
+#define            ORIENTATION_TOPLEFT         1       /* row 0 top, col 0 lhs */
+#define            ORIENTATION_TOPRIGHT        2       /* row 0 top, col 0 rhs */
+#define            ORIENTATION_BOTRIGHT        3       /* row 0 bottom, col 0 rhs */
+#define            ORIENTATION_BOTLEFT         4       /* row 0 bottom, col 0 lhs */
+#define            ORIENTATION_LEFTTOP         5       /* row 0 lhs, col 0 top */
+#define            ORIENTATION_RIGHTTOP        6       /* row 0 rhs, col 0 top */
+#define            ORIENTATION_RIGHTBOT        7       /* row 0 rhs, col 0 bottom */
+#define            ORIENTATION_LEFTBOT         8       /* row 0 lhs, col 0 bottom */
+#define        TIFFTAG_SAMPLESPERPIXEL         277     /* samples per pixel */
+#define        TIFFTAG_ROWSPERSTRIP            278     /* rows per strip of data */
+#define        TIFFTAG_STRIPBYTECOUNTS         279     /* bytes counts for strips */
+#define        TIFFTAG_MINSAMPLEVALUE          280     /* +minimum sample value */
+#define        TIFFTAG_MAXSAMPLEVALUE          281     /* +maximum sample value */
+#define        TIFFTAG_XRESOLUTION             282     /* pixels/resolution in x */
+#define        TIFFTAG_YRESOLUTION             283     /* pixels/resolution in y */
+#define        TIFFTAG_PLANARCONFIG            284     /* storage organization */
+#define            PLANARCONFIG_CONTIG         1       /* single image plane */
+#define            PLANARCONFIG_SEPARATE       2       /* separate planes of data */
+#define        TIFFTAG_PAGENAME                285     /* page name image is from */
+#define        TIFFTAG_XPOSITION               286     /* x page offset of image lhs */
+#define        TIFFTAG_YPOSITION               287     /* y page offset of image lhs */
+#define        TIFFTAG_FREEOFFSETS             288     /* +byte offset to free block */
+#define        TIFFTAG_FREEBYTECOUNTS          289     /* +sizes of free blocks */
+#define        TIFFTAG_GRAYRESPONSEUNIT        290     /* $gray scale curve accuracy */
+#define            GRAYRESPONSEUNIT_10S        1       /* tenths of a unit */
+#define            GRAYRESPONSEUNIT_100S       2       /* hundredths of a unit */
+#define            GRAYRESPONSEUNIT_1000S      3       /* thousandths of a unit */
+#define            GRAYRESPONSEUNIT_10000S     4       /* ten-thousandths of a unit */
+#define            GRAYRESPONSEUNIT_100000S    5       /* hundred-thousandths */
+#define        TIFFTAG_GRAYRESPONSECURVE       291     /* $gray scale response curve */
+#define        TIFFTAG_GROUP3OPTIONS           292     /* 32 flag bits */
+#define            GROUP3OPT_2DENCODING        0x1     /* 2-dimensional coding */
+#define            GROUP3OPT_UNCOMPRESSED      0x2     /* data not compressed */
+#define            GROUP3OPT_FILLBITS          0x4     /* fill to byte boundary */
+#define        TIFFTAG_GROUP4OPTIONS           293     /* 32 flag bits */
+#define            GROUP4OPT_UNCOMPRESSED      0x2     /* data not compressed */
+#define        TIFFTAG_RESOLUTIONUNIT          296     /* units of resolutions */
+#define            RESUNIT_NONE                1       /* no meaningful units */
+#define            RESUNIT_INCH                2       /* english */
+#define            RESUNIT_CENTIMETER          3       /* metric */
+#define        TIFFTAG_PAGENUMBER              297     /* page numbers of multi-page */
+#define        TIFFTAG_COLORRESPONSEUNIT       300     /* $color curve accuracy */
+#define            COLORRESPONSEUNIT_10S       1       /* tenths of a unit */
+#define            COLORRESPONSEUNIT_100S      2       /* hundredths of a unit */
+#define            COLORRESPONSEUNIT_1000S     3       /* thousandths of a unit */
+#define            COLORRESPONSEUNIT_10000S    4       /* ten-thousandths of a unit */
+#define            COLORRESPONSEUNIT_100000S   5       /* hundred-thousandths */
+#define        TIFFTAG_TRANSFERFUNCTION        301     /* !colorimetry info */
+#define        TIFFTAG_SOFTWARE                305     /* name & release */
+#define        TIFFTAG_DATETIME                306     /* creation date and time */
+#define        TIFFTAG_ARTIST                  315     /* creator of image */
+#define        TIFFTAG_HOSTCOMPUTER            316     /* machine where created */
+#define        TIFFTAG_PREDICTOR               317     /* prediction scheme w/ LZW */
+#define        TIFFTAG_WHITEPOINT              318     /* image white point */
+#define        TIFFTAG_PRIMARYCHROMATICITIES   319     /* !primary chromaticities */
+#define        TIFFTAG_COLORMAP                320     /* RGB map for pallette image */
+#define        TIFFTAG_HALFTONEHINTS           321     /* !highlight+shadow info */
+#define        TIFFTAG_TILEWIDTH               322     /* !rows/data tile */
+#define        TIFFTAG_TILELENGTH              323     /* !cols/data tile */
+#define TIFFTAG_TILEOFFSETS            324     /* !offsets to data tiles */
+#define TIFFTAG_TILEBYTECOUNTS         325     /* !byte counts for tiles */
+#define        TIFFTAG_BADFAXLINES             326     /* lines w/ wrong pixel count */
+#define        TIFFTAG_CLEANFAXDATA            327     /* regenerated line info */
+#define            CLEANFAXDATA_CLEAN          0       /* no errors detected */
+#define            CLEANFAXDATA_REGENERATED    1       /* receiver regenerated lines */
+#define            CLEANFAXDATA_UNCLEAN        2       /* uncorrected errors exist */
+#define        TIFFTAG_CONSECUTIVEBADFAXLINES  328     /* max consecutive bad lines */
+#define        TIFFTAG_SUBIFD                  330     /* subimage descriptors */
+#define        TIFFTAG_INKSET                  332     /* !inks in separated image */
+#define            INKSET_CMYK                 1       /* !cyan-magenta-yellow-black */
+#define        TIFFTAG_INKNAMES                333     /* !ascii names of inks */
+#define        TIFFTAG_DOTRANGE                336     /* !0% and 100% dot codes */
+#define        TIFFTAG_TARGETPRINTER           337     /* !separation target */
+#define        TIFFTAG_EXTRASAMPLES            338     /* !info about extra samples */
+#define            EXTRASAMPLE_UNSPECIFIED     0       /* !unspecified data */
+#define            EXTRASAMPLE_ASSOCALPHA      1       /* !associated alpha data */
+#define            EXTRASAMPLE_UNASSALPHA      2       /* !unassociated alpha data */
+#define        TIFFTAG_SAMPLEFORMAT            339     /* !data sample format */
+#define            SAMPLEFORMAT_UINT           1       /* !unsigned integer data */
+#define            SAMPLEFORMAT_INT            2       /* !signed integer data */
+#define            SAMPLEFORMAT_IEEEFP         3       /* !IEEE floating point data */
+#define            SAMPLEFORMAT_VOID           4       /* !untyped data */
+#define        TIFFTAG_SMINSAMPLEVALUE         340     /* !variable MinSampleValue */
+#define        TIFFTAG_SMAXSAMPLEVALUE         341     /* !variable MaxSampleValue */
+#define        TIFFTAG_JPEGTABLES              347     /* %JPEG table stream */
+/*
+ * Tags 512-521 are obsoleted by Technical Note #2
+ * which specifies a revised JPEG-in-TIFF scheme.
+ */
+#define        TIFFTAG_JPEGPROC                512     /* !JPEG processing algorithm */
+#define            JPEGPROC_BASELINE           1       /* !baseline sequential */
+#define            JPEGPROC_LOSSLESS           14      /* !Huffman coded lossless */
+#define        TIFFTAG_JPEGIFOFFSET            513     /* !pointer to SOI marker */
+#define        TIFFTAG_JPEGIFBYTECOUNT         514     /* !JFIF stream length */
+#define        TIFFTAG_JPEGRESTARTINTERVAL     515     /* !restart interval length */
+#define        TIFFTAG_JPEGLOSSLESSPREDICTORS  517     /* !lossless proc predictor */
+#define        TIFFTAG_JPEGPOINTTRANSFORM      518     /* !lossless point transform */
+#define        TIFFTAG_JPEGQTABLES             519     /* !Q matrice offsets */
+#define        TIFFTAG_JPEGDCTABLES            520     /* !DCT table offsets */
+#define        TIFFTAG_JPEGACTABLES            521     /* !AC coefficient offsets */
+#define        TIFFTAG_YCBCRCOEFFICIENTS       529     /* !RGB -> YCbCr transform */
+#define        TIFFTAG_YCBCRSUBSAMPLING        530     /* !YCbCr subsampling factors */
+#define        TIFFTAG_YCBCRPOSITIONING        531     /* !subsample positioning */
+#define            YCBCRPOSITION_CENTERED      1       /* !as in PostScript Level 2 */
+#define            YCBCRPOSITION_COSITED       2       /* !as in CCIR 601-1 */
+#define        TIFFTAG_REFERENCEBLACKWHITE     532     /* !colorimetry info */
+/* tags 32952-32956 are private tags registered to Island Graphics */
+#define TIFFTAG_REFPTS                 32953   /* image reference points */
+#define TIFFTAG_REGIONTACKPOINT                32954   /* region-xform tack point */
+#define TIFFTAG_REGIONWARPCORNERS      32955   /* warp quadrilateral */
+#define TIFFTAG_REGIONAFFINE           32956   /* affine transformation mat */
+/* tags 32995-32999 are private tags registered to SGI */
+#define        TIFFTAG_MATTEING                32995   /* $use ExtraSamples */
+#define        TIFFTAG_DATATYPE                32996   /* $use SampleFormat */
+#define        TIFFTAG_IMAGEDEPTH              32997   /* z depth of image */
+#define        TIFFTAG_TILEDEPTH               32998   /* z depth/data tile */
+/* tags 33300-33309 are private tags registered to Pixar */
+/*
+ * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH
+ * are set when an image has been cropped out of a larger image.  
+ * They reflect the size of the original uncropped image.
+ * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used
+ * to determine the position of the smaller image in the larger one.
+ */
+#define TIFFTAG_PIXAR_IMAGEFULLWIDTH    33300   /* full image size in x */
+#define TIFFTAG_PIXAR_IMAGEFULLLENGTH   33301   /* full image size in y */
+/* tag 33405 is a private tag registered to Eastman Kodak */
+#define TIFFTAG_WRITERSERIALNUMBER      33405   /* device serial number */
+/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
+#define        TIFFTAG_COPYRIGHT               33432   /* copyright string */
+/* tags 34232-34236 are private tags registered to Texas Instruments */
+#define TIFFTAG_FRAMECOUNT              34232   /* Sequence Frame Count */
+/* tag 34750 is a private tag registered to Pixel Magic */
+#define        TIFFTAG_JBIGOPTIONS             34750   /* JBIG options */
+/* tags 34908-34914 are private tags registered to SGI */
+#define        TIFFTAG_FAXRECVPARAMS           34908   /* encoded Class 2 ses. parms */
+#define        TIFFTAG_FAXSUBADDRESS           34909   /* received SubAddr string */
+#define        TIFFTAG_FAXRECVTIME             34910   /* receive time (secs) */
+/* tag 65535 is an undefined tag used by Eastman Kodak */
+#define TIFFTAG_DCSHUESHIFTVALUES       65535   /* hue shift correction data */
+
+/*
+ * The following are ``pseudo tags'' that can be
+ * used to control codec-specific functionality.
+ * These tags are not written to file.  Note that
+ * these values start at 0xffff+1 so that they'll
+ * never collide with Aldus-assigned tags.
+ *
+ * If you want your private pseudo tags ``registered''
+ * (i.e. added to this file), send mail to sam@sgi.com
+ * with the appropriate C definitions to add.
+ */
+#define        TIFFTAG_FAXMODE                 65536   /* Group 3/4 format control */
+#define            FAXMODE_CLASSIC     0x0000          /* default, include RTC */
+#define            FAXMODE_NORTC       0x0001          /* no RTC at end of data */
+#define            FAXMODE_NOEOL       0x0002          /* no EOL code at end of row */
+#define            FAXMODE_BYTEALIGN   0x0004          /* byte align row */
+#define            FAXMODE_WORDALIGN   0x0008          /* word align row */
+#define            FAXMODE_CLASSF      FAXMODE_NORTC   /* TIFF Class F */
+#define        TIFFTAG_JPEGQUALITY             65537   /* Compression quality level */
+/* Note: quality level is on the IJG 0-100 scale.  Default value is 75 */
+#define        TIFFTAG_JPEGCOLORMODE           65538   /* Auto RGB<=>YCbCr convert? */
+#define            JPEGCOLORMODE_RAW   0x0000          /* no conversion (default) */
+#define            JPEGCOLORMODE_RGB   0x0001          /* do auto conversion */
+#define        TIFFTAG_JPEGTABLESMODE          65539   /* What to put in JPEGTables */
+#define            JPEGTABLESMODE_QUANT 0x0001         /* include quantization tbls */
+#define            JPEGTABLESMODE_HUFF 0x0002          /* include Huffman tbls */
+/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */
+#define        TIFFTAG_FAXFILLFUNC             65540   /* G3/G4 fill function */
+#define        TIFFTAG_PIXARLOGDATAFMT         65549   /* PixarLogCodec I/O data sz */
+#define            PIXARLOGDATAFMT_8BIT        0       /* regular u_char samples */
+#define            PIXARLOGDATAFMT_8BITABGR    1       /* ABGR-order u_chars */
+#define            PIXARLOGDATAFMT_11BITLOG    2       /* 11-bit log-encoded (raw) */
+#define            PIXARLOGDATAFMT_12BITPICIO  3       /* as per PICIO (1.0==2048) */
+#define            PIXARLOGDATAFMT_16BIT       4       /* signed short samples */
+#define            PIXARLOGDATAFMT_FLOAT       5       /* IEEE float samples */
+/* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */
+#define TIFFTAG_DCSIMAGERTYPE           65550   /* imager model & filter */
+#define     DCSIMAGERMODEL_M3           0       /* M3 chip (1280 x 1024) */
+#define     DCSIMAGERMODEL_M5           1       /* M5 chip (1536 x 1024) */
+#define     DCSIMAGERMODEL_M6           2       /* M6 chip (3072 x 2048) */
+#define     DCSIMAGERFILTER_IR          0       /* infrared filter */
+#define     DCSIMAGERFILTER_MONO        1       /* monochrome filter */
+#define     DCSIMAGERFILTER_CFA         2       /* color filter array */
+#define     DCSIMAGERFILTER_OTHER       3       /* other filter */
+#define TIFFTAG_DCSINTERPMODE           65551   /* interpolation mode */
+#define     DCSINTERPMODE_NORMAL        0x0     /* whole image, default */
+#define     DCSINTERPMODE_PREVIEW       0x1     /* preview of image (384x256) */
+#define TIFFTAG_DCSBALANCEARRAY         65552   /* color balance values */
+#define TIFFTAG_DCSCORRECTMATRIX        65553   /* color correction values */
+#define TIFFTAG_DCSGAMMA                65554   /* gamma value */
+#define TIFFTAG_DCSTOESHOULDERPTS       65555   /* toe & shoulder points */
+#define TIFFTAG_DCSCALIBRATIONFD        65556   /* calibration file desc */
+/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */
+#define        TIFFTAG_ZIPQUALITY              65557   /* compression quality level */
+#define        TIFFTAG_PIXARLOGQUALITY         65558   /* PixarLog uses same scale */
+#endif /* _TIFF_ */
diff --git a/libs/libtiff/tiffio.h b/libs/libtiff/tiffio.h
new file mode 100644 (file)
index 0000000..2c1e16f
--- /dev/null
@@ -0,0 +1,311 @@
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffio.h,v 1.93 1996/03/07 17:00:14 sam Rel $ */
+
+/*
+ * Copyright (c) 1988-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _TIFFIO_
+#define        _TIFFIO_
+
+/*
+ * TIFF I/O Library Definitions.
+ */
+#include "tiff.h"
+
+/*
+ * This define can be used in code that requires
+ * compilation-related definitions specific to a
+ * version or versions of the library.  Runtime
+ * version checking should be done based on the
+ * string returned by TIFFGetVersion.
+ */
+#define        TIFFLIB_VERSION 19960307        /* March 7, 1996 */
+
+/*
+ * TIFF is defined as an incomplete type to hide the
+ * library's internal data structures from clients.
+ */
+typedef        struct tiff TIFF;
+
+/*
+ * The following typedefs define the intrinsic size of
+ * data types used in the *exported* interfaces.  These
+ * definitions depend on the proper definition of types
+ * in tiff.h.  Note also that the varargs interface used
+ * pass tag types and values uses the types defined in
+ * tiff.h directly.
+ *
+ * NB: ttag_t is unsigned int and not unsigned short because
+ *     ANSI C requires that the type before the ellipsis be a
+ *     promoted type (i.e. one of int, unsigned int, pointer,
+ *     or double) and because we defined pseudo-tags that are
+ *     outside the range of legal Aldus-assigned tags.
+ * NB: tsize_t is int32 and not uint32 because some functions
+ *     return -1.
+ * NB: toff_t is not off_t for many reasons; TIFFs max out at
+ *     32-bit file offsets being the most important
+ */
+typedef        unsigned int ttag_t;    /* directory tag */
+typedef        uint16 tdir_t;          /* directory index */
+typedef        uint16 tsample_t;       /* sample number */
+typedef        uint32 tstrip_t;        /* strip number */
+typedef uint32 ttile_t;                /* tile number */
+typedef        int32 tsize_t;          /* i/o size in bytes */
+#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
+#include <windows.h>
+#ifdef __WIN32__
+DECLARE_HANDLE(thandle_t);     /* Win32 file handle */
+#else
+typedef        HFILE thandle_t;        /* client data handle */
+#endif
+#else
+typedef        void* thandle_t;        /* client data handle */
+#endif
+typedef        void* tdata_t;          /* image data ref */
+typedef        int32 toff_t;           /* file offset */
+
+#ifndef NULL
+#define        NULL    0
+#endif
+
+/*
+ * Flags to pass to TIFFPrintDirectory to control
+ * printing of data structures that are potentially
+ * very large.   Bit-or these flags to enable printing
+ * multiple items.
+ */
+#define        TIFFPRINT_NONE          0x0             /* no extra info */
+#define        TIFFPRINT_STRIPS        0x1             /* strips/tiles info */
+#define        TIFFPRINT_CURVES        0x2             /* color/gray response curves */
+#define        TIFFPRINT_COLORMAP      0x4             /* colormap */
+#define        TIFFPRINT_JPEGQTABLES   0x100           /* JPEG Q matrices */
+#define        TIFFPRINT_JPEGACTABLES  0x200           /* JPEG AC tables */
+#define        TIFFPRINT_JPEGDCTABLES  0x200           /* JPEG DC tables */
+
+/*
+ * RGBA-style image support.
+ */
+typedef        unsigned char TIFFRGBValue;             /* 8-bit samples */
+typedef struct _TIFFRGBAImage TIFFRGBAImage;
+/*
+ * The image reading and conversion routines invoke
+ * ``put routines'' to copy/image/whatever tiles of
+ * raw image data.  A default set of routines are 
+ * provided to convert/copy raw image data to 8-bit
+ * packed ABGR format rasters.  Applications can supply
+ * alternate routines that unpack the data into a
+ * different format or, for example, unpack the data
+ * and draw the unpacked raster on the display.
+ */
+typedef void (*tileContigRoutine)
+    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
+       unsigned char*);
+typedef void (*tileSeparateRoutine)
+    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
+       unsigned char*, unsigned char*, unsigned char*, unsigned char*);
+/*
+ * RGBA-reader state.
+ */
+typedef struct {                               /* YCbCr->RGB support */
+       TIFFRGBValue* clamptab;                 /* range clamping table */
+       int*    Cr_r_tab;
+       int*    Cb_b_tab;
+       int32*  Cr_g_tab;
+       int32*  Cb_g_tab;
+       float   coeffs[3];                      /* cached for repeated use */
+} TIFFYCbCrToRGB;
+
+struct _TIFFRGBAImage {
+       TIFF*   tif;                            /* image handle */
+       int     stoponerr;                      /* stop on read error */
+       int     isContig;                       /* data is packed/separate */
+       int     alpha;                          /* type of alpha data present */
+       uint32  width;                          /* image width */
+       uint32  height;                         /* image height */
+       uint16  bitspersample;                  /* image bits/sample */
+       uint16  samplesperpixel;                /* image samples/pixel */
+       uint16  orientation;                    /* image orientation */
+       uint16  photometric;                    /* image photometric interp */
+       uint16* redcmap;                        /* colormap pallete */
+       uint16* greencmap;
+       uint16* bluecmap;
+                                               /* get image data routine */
+       int     (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
+       union {
+           void (*any)(TIFFRGBAImage*);
+           tileContigRoutine   contig;
+           tileSeparateRoutine separate;
+       } put;                                  /* put decoded strip/tile */
+       TIFFRGBValue* Map;                      /* sample mapping array */
+       uint32** BWmap;                         /* black&white map */
+       uint32** PALmap;                        /* palette image map */
+       TIFFYCbCrToRGB* ycbcr;                  /* YCbCr conversion state */
+};
+
+/*
+ * Macros for extracting components from the
+ * packed ABGR form returned by TIFFReadRGBAImage.
+ */
+#define        TIFFGetR(abgr)  ((abgr) & 0xff)
+#define        TIFFGetG(abgr)  (((abgr) >> 8) & 0xff)
+#define        TIFFGetB(abgr)  (((abgr) >> 16) & 0xff)
+#define        TIFFGetA(abgr)  (((abgr) >> 24) & 0xff)
+
+/*
+ * A CODEC is a software package that implements decoding,
+ * encoding, or decoding+encoding of a compression algorithm.
+ * The library provides a collection of builtin codecs.
+ * More codecs may be registered through calls to the library
+ * and/or the builtin implementations may be overridden.
+ */
+typedef        int (*TIFFInitMethod)(TIFF*, int);
+typedef struct {
+       char*           name;
+       uint16          scheme;
+       TIFFInitMethod  init;
+} TIFFCodec;
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+typedef        void (*TIFFErrorHandler)(const char*, const char*, va_list);
+typedef        tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
+typedef        toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
+typedef        int (*TIFFCloseProc)(thandle_t);
+typedef        toff_t (*TIFFSizeProc)(thandle_t);
+typedef        int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
+typedef        void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
+typedef        void (*TIFFExtendProc)(TIFF*); 
+
+extern const char* TIFFGetVersion(void);
+
+extern const TIFFCodec* TIFFFindCODEC(uint16);
+extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
+extern void TIFFUnRegisterCODEC(TIFFCodec*);
+
+extern tdata_t _TIFFmalloc(tsize_t);
+extern tdata_t _TIFFrealloc(tdata_t, tsize_t);
+extern void _TIFFmemset(tdata_t, int, tsize_t);
+extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
+extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
+extern void _TIFFfree(tdata_t);
+
+extern void TIFFClose(TIFF*);
+extern int TIFFFlush(TIFF*);
+extern int TIFFFlushData(TIFF*);
+extern int TIFFGetField(TIFF*, ttag_t, ...);
+extern int TIFFVGetField(TIFF*, ttag_t, va_list);
+extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
+extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
+extern int TIFFReadDirectory(TIFF*);
+extern tsize_t TIFFScanlineSize(TIFF*);
+extern tsize_t TIFFRasterScanlineSize(TIFF*);
+extern tsize_t TIFFStripSize(TIFF*);
+extern tsize_t TIFFVStripSize(TIFF*, uint32);
+extern tsize_t TIFFTileRowSize(TIFF*);
+extern tsize_t TIFFTileSize(TIFF*);
+extern tsize_t TIFFVTileSize(TIFF*, uint32);
+extern uint32 TIFFDefaultStripSize(TIFF*, uint32);
+extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
+extern int TIFFFileno(TIFF*);
+extern int TIFFGetMode(TIFF*);
+extern int TIFFIsTiled(TIFF*);
+extern int TIFFIsByteSwapped(TIFF*);
+extern int TIFFIsUpSampled(TIFF*);
+extern int TIFFIsMSB2LSB(TIFF*);
+extern uint32 TIFFCurrentRow(TIFF*);
+extern tdir_t TIFFCurrentDirectory(TIFF*);
+extern uint32 TIFFCurrentDirOffset(TIFF*);
+extern tstrip_t TIFFCurrentStrip(TIFF*);
+extern ttile_t TIFFCurrentTile(TIFF*);
+extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
+extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
+extern int TIFFLastDirectory(TIFF*);
+extern int TIFFSetDirectory(TIFF*, tdir_t);
+extern int TIFFSetSubDirectory(TIFF*, uint32);
+extern int TIFFUnlinkDirectory(TIFF*, tdir_t);
+extern int TIFFSetField(TIFF*, ttag_t, ...);
+extern int TIFFVSetField(TIFF*, ttag_t, va_list);
+extern int TIFFWriteDirectory(TIFF *);
+#if defined(c_plusplus) || defined(__cplusplus)
+extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
+extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
+extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
+extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
+#else
+extern void TIFFPrintDirectory(TIFF*, FILE*, long);
+extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
+extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
+extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
+#endif
+extern int TIFFRGBAImageOK(TIFF*, char [1024]);
+extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
+extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
+extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
+extern TIFF* TIFFOpen(const char*, const char*);
+extern TIFF* TIFFFdOpen(int, const char*, const char*);
+extern TIFF* TIFFClientOpen(const char*, const char*,
+           thandle_t,
+           TIFFReadWriteProc, TIFFReadWriteProc,
+           TIFFSeekProc, TIFFCloseProc,
+           TIFFSizeProc,
+           TIFFMapFileProc, TIFFUnmapFileProc);
+extern const char* TIFFFileName(TIFF*);
+extern void TIFFError(const char*, const char*, ...);
+extern void TIFFWarning(const char*, const char*, ...);
+extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
+extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
+extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
+extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
+extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
+extern ttile_t TIFFNumberOfTiles(TIFF*);
+extern tsize_t TIFFReadTile(TIFF*,
+           tdata_t, uint32, uint32, uint32, tsample_t);
+extern tsize_t TIFFWriteTile(TIFF*,
+           tdata_t, uint32, uint32, uint32, tsample_t);
+extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
+extern tstrip_t TIFFNumberOfStrips(TIFF*);
+extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
+extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
+extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
+extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
+extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
+extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
+extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
+extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
+extern void TIFFSetWriteOffset(TIFF*, toff_t);
+extern void TIFFSwabShort(uint16*);
+extern void TIFFSwabLong(uint32*);
+extern void TIFFSwabDouble(double*);
+extern void TIFFSwabArrayOfShort(uint16*, unsigned long);
+extern void TIFFSwabArrayOfLong(uint32*, unsigned long);
+extern void TIFFSwabArrayOfDouble(double*, unsigned long);
+extern void TIFFReverseBits(unsigned char *, unsigned long);
+extern const unsigned char* TIFFGetBitRevTable(int);
+#if defined(__cplusplus)
+}
+#endif
+#endif /* _TIFFIO_ */