I\'d like to use LibTiff to access very large TIFF files. I need functions like multiple pages and tiles, and so LibTiff seems to be the right way to go. Can anyone help me
My initial solution was to use a C#.NET wrapper for the LibTIFF DLL. I have found it on libtiff ftp. It seems to contain all important methods of the LIBTiff library. It keeps memory in unmanaged LibTIFF memory; this means that the C# code needs to be aware of this and copy data when it needs to be processed in safe code.
My 'tile reading code' to test it read like
if (LibTIFF.IsTiled(tiff))
{
if (LibTIFF.GetField(tiff, (int)TIFFTags.TIFFTAG_TILEWIDTH, out tileWidth) &&
LibTIFF.GetField(tiff, (int)TIFFTags.TIFFTAG_TILELENGTH, out tileLength))
{
uint tiles = 0;
IntPtr pTile = LibTIFF._malloc((int)(tileLength*tileWidth*bitsPerSample/2));
for (uint y = 0; y < imageLength; y += tileLength)
{
for (uint x = 0; x < imageWidth; x += tileWidth)
{
LibTIFF.ReadTile(tiff, pTile, x, y, 0, 0);
tiles++;
}
}
LibTIFF._free(pTile);
}
}
I'll go for the .NET port of LibTIFF though, but this solution may be the right one for other people, so I leave it on StackOverflow.