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
WIC provides support for very large image files. There's a nice wrapper for it in the .NET framework: TiffBitmapDecoder.
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.
You can try our LibTiff.Net. It is free and open source version of LibTiff written using managed C#. API of our implementation kept very similar to original one's.
https://bitmiracle.com/libtiff/
We've just released it, so there may be bugs. But full source code comes with a number of test, so most obvious bugs should be fixed.