在C#中使用32位TIFF

时间:2017-11-13 20:28:12

标签: c# image-processing tiff

我正在尝试将32位TIFF导入到我的程序中。由于tiff是多页面,我将其作为图像导入,然后使用流将其转换为位图。这与8位多页tiff完美配合,但是对于32位图像,它会以正确的尺寸喷出正确数量的图像,但是作为8位图像,每个像素都是白色。这个问题似乎与输入有关,因为我已经在流之前使用图像尝试了代码并且它仍然是白色的。这是我的代码:

System.Drawing.Image sampleTiffImage = System.Drawing.Image.FromFile(openFileDialog1.FileName);
//this line is probably the one causing the issue

int pageCount = sampleTiffImage.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);

for (int pageNum = 0; pageNum < pageCount; pageNum++)
{
    sampleTiffImage.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, pageNum);
    using (MemoryStream memStream = new MemoryStream())
    {
        sampleTiffImage.Save(memStream, ImageFormat.Bmp);
        using (Bitmap myBitmap = (Bitmap)Bitmap.FromStream(memStream))
        {
            //I make other stuff happen here but I have this in for display/debugging.
            myBitmap.Save(@"Save Location" + pageNum + ".bmp");

        }
    }
}

0 个答案:

没有答案