2007.03.23 10:16 "[Tiff] Multipage tiff", by George Nianios

2007.03.23 17:38 "[Tiff] Re: Tiff Digest, Vol 34, Issue 16", by George Nianios

> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 23 Mar 2007 12:16:26 +0200
> From: "George Nianios" <nianios@gmail.com>
> Subject: [Tiff] Multipage tiff
> To: tiff@lists.maptools.org
> Message-ID:
> <cf8a3960703230316q36ff3c7cp56307589cd50fc16@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I have problems in reading multipage tiff files. Until now i can read a single tiff image and put each pixel's information in a GLubyte array. Now i want to do the same with a multipage tiff. I am quite new in image processing and any help is valuable.

Hello again i solve my problem,

Many thanks to Andrey Kiselev for helping me.

Now i am in front of a small problem. My code is

/*read one tif and put it in an array*/
void read_tiff(TIFF *tif,int w,int h,int dir)
{
TIFFReadRGBAImage(tif, w, h, raster, 0);
int i,j;
for(i=0;i<h-1;i++){
for(j=0;j<w-1;j++){
frame[dir*w*h+i*h+j]=raster[i*h+j];
}
}
}
/*read one tif*/

main(int argc, char* argv[])
{

    TIFF *tif;
if ((tif = TIFFOpen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Could not open file to read.\n");
    exit(1);
  }
if (tif) {
         do {
             dircount++;
         } while (TIFFReadDirectory(tif));
         printf("%d directories in %s\n", dircount, argv[1]);
              }

 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);

int npixels=width*height*dircount;
 raster=(uint32 *) _TIFFmalloc(npixels*sizeof(uint32));

int i;
for (i=0;i<dircount-1;i++)
{
TIFFSetDirectory(tif,i);
read_tiff(tif,width,height,i);
 }
_TIFFfree(raster);
TIFFClose(tif);

With this code i put in frame[] color info from each single tiff page from one multipage tiff.

But gcc returns me for image the same warning:

TIFFReadDirectory: Warning, multitest.tif: invalid TIFF directory; tags are not sorted in ascending order.

multitest.tif: Warning, incorrect count for field "DateTime" (44, expecting 20); tag trimmed.

I know that this warning becomes from this routine:

if (tif) {
         do {
             dircount++;
         } while (TIFFReadDirectory(tif));
         printf("%d directories in %s\n", dircount, argv[1]);
              }

and i know that my multipage tiff is not the proper but i am wondering if i could pass these warnings. I have this routine only because i want to count the sum of the pages of the multipage tiff. Do you know another way to do it?

Thanks for your time

--
GEORGE NIANIOS