I am trying to load a 32-bit TIFF and read the RGBA values of the pixels. I have tried using LibTiff.Net, however I get this error when attempting to load it:
"Sorry, can not handle images with 32-bit samples"
Does anyone know of a way to accomplish this in C#? I don't want to reduce the pixel depth as these images contain data which will be used in scientific calculations.
Thanks for any and all help.
EDIT: Example:
var stream = File.Open(fileName, FileMode.Open);
TiffBitmapDecoder tiffDecoder = new TiffBitmapDecoder( stream,
BitmapCreateOptions.PreservePixelFormat | BitmapCreateOptions.IgnoreImageCache,
BitmapCacheOption.None);
stream.Dispose();
BitmapSource bmpSource = tiffDecoder.Frames[0];
byte[] data;
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmpSource));
using (MemoryStream ms = new MemoryStream())
{
encoder.Save(ms);
data = ms.ToArray();
}
This give me the following error:
{"The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))"}
On the line
encoder.Frames.Add(BitmapFrame.Create(bmpSource));
User contributions licensed under CC BY-SA 3.0