如何在.NET 2.0中打开一个多帧TIFF图像的imageformat? [英] How to open a multi-frame TIFF imageformat image in .NET 2.0?

查看:150
本文介绍了如何在.NET 2.0中打开一个多帧TIFF图像的imageformat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Image.FromFile(@"path\filename.tif")

Image.FromStream(memoryStream)

既产生图像对象与即使源是一个多帧TIFF文件仅一帧。 如何加载,保留这些帧图像文件?的TIFF格式使用由帧Image.SaveAdd方法框架保存。他们其他观众的工作,但.NET图像的方法将不会加载这些帧,只有第一。

both produce image objects with only one frame even though the source is a multi-frame TIFF file. How do you load an image file that retains these frames? The tiffs are saved using the Image.SaveAdd methods frame by frame. They work in other viewers but .NET Image methods will not load these frames, only the first.

这是否意味着有没有办法从那里我传递位图的集合被用作帧的方法返回一个多帧TIFF ?

推荐答案

下面是我用什么:

private List<Image> GetAllPages(string file)
{
    List<Image> images = new List<Image>();
    Bitmap bitmap = (Bitmap)Image.FromFile(file);
    int count = bitmap.GetFrameCount(FrameDimension.Page);
    for (int idx = 0; idx < count; idx++)
    {
        // save each frame to a bytestream
        bitmap.SelectActiveFrame(FrameDimension.Page, idx);
        MemoryStream byteStream = new MemoryStream();
        bitmap.Save(byteStream, ImageFormat.Tiff);

        // and then create a new Image from it
        images.Add(Image.FromStream(byteStream));
    }
    return images;
}

这篇关于如何在.NET 2.0中打开一个多帧TIFF图像的imageformat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆