加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在C#中显示GIF图像的特定帧?

发布时间:2020-12-16 02:04:12 所属栏目:百科 来源:网络整理
导读:我想展示一个gif图像的框架.我搜索并发现以下代码应该可以工作,但它不起作用.它正确检测帧数,但它显示的是gif的整个帧而不是指定的帧.谢谢大家. Image[] frames = new Image[36];Image GG = Image.FromFile(@"C:UsersAdministratorTEST C#TEST2frame2ch
我想展示一个gif图像的框架.我搜索并发现以下代码应该可以工作,但它不起作用.它正确检测帧数,但它显示的是gif的整个帧而不是指定的帧.谢谢大家.

Image[] frames = new Image[36];
Image GG = Image.FromFile(@"C:UsersAdministratorTEST C#TEST2frame2chef.gif");
FrameDimension dimension = new FrameDimension(GG.FrameDimensionsList[0]);
            // Number of frames
int frameCount = GG.GetFrameCount(dimension);
label1.Text = frameCount.ToString();

            // Return an Image at a certain index
GG.SelectActiveFrame(dimension,1);
frames[1] = ((Image)GG.Clone());
pictureBox1.Image = frames[1];

解决方法

使用您自己的代码,直到调用SelectActiveFrame(),然后更改为以下行:

frames[0] = new Bitmap(GG);
pictureBox1.Image = frame[0];

这应该可以解决问题.请不要忘记处理创建的图像.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读