Reputation: 384
I have a gray-scale TIFF image which windows properties say its Bit-depth is 4 (which is supposed to mean it is 4 BPP), but when I open the image in C# as a bitmap the pixelFormat property says it is Format8bppIndexed (8 BPP), is it the bitmap constructor changing the pixel format or I misunderstood something?
Upvotes: 0
Views: 156
Reputation: 116
The TIFF format is an container (like ZIP). One TIFF file can contain various frames containing different files / data. An frame can be a bitmap. And each bitmap can have a different pixelFormat. A TIFF file can (or could) have a preview bitmap that has a different pixelFormat.
To get the actual pixelformat of the first frame you could use this :
Stream imageStreamSource = new FileStream("file.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
PixelFormat pixelFormat = bitmapSource.Format;
Upvotes: 1