I am having trouble loading Tiff files in C#. I downloaded some sample tiff files and was able to load them fine, however when I attempt to load any tiff files generated from PCI Geomatica or ArcGIS, the ReadRGBAImage call fails (returns false). Other than IMAGEWIDTH and IMAGELENGTH, all of the other tags I've tried to retrieve have returned null (eg. XRESOLUTION). Does anyone have any ideas as to why this is happening? The relevant code is below:
using (Tiff tif = Tiff.Open(fileName, "r"))
{
// Find the width and height of the image
FieldValue[] value = tif.GetField(TiffTag.IMAGEWIDTH);
int width = value[0].ToInt();
value = tif.GetField(TiffTag.IMAGELENGTH);
int height = value[0].ToInt();
// Read the image into the memory buffer
int[] raster = new int[height * width];
if (!tif.ReadRGBAImage(width, height, raster))
{
System.Windows.Forms.MessageBox.Show("Could not read image");
return null;
}
}
Thanks!