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

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
September 2007

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

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



Valid HTML 4.01!



Thread

2007.09.27 07:34 "add pages in BigTiff", by <tobykaos@free.fr>
2007.09.27 10:29 "Re: add pages in BigTiff", by Joris Van Damme
2007.09.27 10:48 "Re: add pages in BigTiff", by Andrey Kiselev

2007.09.27 07:34 "add pages in BigTiff", by <tobykaos@free.fr>

Hello,

I try to append new pages in a bigtif file. While my tiff is under 4Go size,
this work well. But after this size, number of page restart to 1. I can append
others pages and my bigtiff grow up. I have a 6.8Go bigtiff size file with 2
pages. But indeed there are 5 pages. Why??

My append function is:


void IM_Tools::append(const char *fileName, char *fileAdd)
{
  TIFF *in, *add;

  if((in = TIFFOpen(fileName, "a"))==NULL)
    throw IM_LoadingFailed(fileName, (const char*)printf("Erreur de chargement
directory: %u", 0) );

  unsigned short int nbPages, pg0 = 0;
  nbPages = TIFFNumberOfDirectories(in);

  TIFFSetField(in, TIFFTAG_PAGENUMBER, nbPages++, pg0);

  TIFFReadDirectory(in);

  if((add = TIFFOpen(fileAdd, "r"))==NULL)
    throw IM_LoadingFailed(fileAdd, (const char*)printf("Erreur de chargement
directory: %u", 0) );

  tiffcp(add, in);

  TIFFWriteDirectory(in);

  TIFFClose(add);
  TIFFClose(in);

}



int IM_Tools::tiffcp(TIFF* in, TIFF* out)
{
	cpFields(in, out);
	if (TIFFIsTiled(in))
		return (cpTiles(in, out));
	else
		return (cpStrips(in, out));
}




int IM_Tools::cpTiles(TIFF* in, TIFF* out)
{
 unsigned short int dtx, dty, ftx, fty;
  unsigned int width = 0;
  TIFFGetField(out, TIFFTAG_IMAGEWIDTH, &width);
  unsigned int height = 0;
  TIFFGetField(out, TIFFTAG_IMAGELENGTH, &height);

  ftx = (unsigned short int)ceil((float)width/240.0f);

  fty = (unsigned short int)ceil((float)height/240.0f);

  uint8* buffer;

   if((buffer=(uint8*)malloc(TIFFTileSize(in))) == NULL) {
      TIFFClose(in);
      return 0;
    }

    for (dty = 0; dty < fty; dty++) {
      for(dtx = 0; dtx < ftx; dtx++)
      {
      /* Lecture et conversion de la tuile */
        if(TIFFReadTile(in, buffer, dtx*240, dty*240, 0, 0) < 0 ||
TIFFWriteTile(out, buffer,240*dtx, 240*dty, 0, 0) < 0) {

          return 0;
        }
    }
    }

  free(buffer);
  return 1;
}

I use libtiff 4.0.

Thanks.