我LibTiff.NET
用来读取多页 Tiff 文件。将我的 Tiff 转换为 a 没有问题System.Drawing.Bitmap
,因为它显示在他们的网站上,但我想要的是 aBitmapSource
或与使用 in 相当的东西WPF
。当然,我已经可以转换了converted System.Drawing.Bitmap
,但是由于数据量很大,我正在寻找一种方法,直接从Tiff object
.
有什么建议么?也许使用 ReadRGBAImage 方法,它返回一个带有颜色的 int 数组?
编辑1:
我尝试了以下方法,但只得到了由灰色条纹组成的图像:
int[] raster = new int[height * width];
im.ReadRGBAImage(width, height, raster);
byte[] bytes = new byte[raster.Length * sizeof(int)];
Buffer.BlockCopy(raster, 0, bytes, 0, bytes.Length);
int stride = raster.Length / height;
image.Source = BitmapSource.Create(
width, height, dpiX/*ex 96*/, dpiY/*ex 96*/,
PixelFormats.Indexed1, BitmapPalettes.BlackAndWhite, bytes,
/*32/*bytes/pixel * width*/ stride);
编辑2:
也许这有帮助,它是为了转换为System.Drawing.Bitmap
.