【发布时间】:2015-03-04 20:16:03
【问题描述】:
我有一个灰度 TIFF 图像,Windows 属性说它的位深度是 4(这应该意味着它是 4 BPP),但是当我在 C# 中将图像作为位图打开时,pixelFormat 属性说它是Format8bppIndexed(8 BPP),是位图构造函数改变了像素格式还是我误解了什么?
【问题讨论】:
我有一个灰度 TIFF 图像,Windows 属性说它的位深度是 4(这应该意味着它是 4 BPP),但是当我在 C# 中将图像作为位图打开时,pixelFormat 属性说它是Format8bppIndexed(8 BPP),是位图构造函数改变了像素格式还是我误解了什么?
【问题讨论】:
TIFF 格式是一个容器(如 ZIP)。一个 TIFF 文件可以包含包含不同文件/数据的各种帧。帧可以是位图。并且每个位图可以有不同的pixelFormat。 TIFF 文件可以(或可以)具有具有不同像素格式的预览位图。
要获得第一帧的实际像素格式,您可以使用:
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;
【讨论】: