在Wpf中使用动态GIF图像的简单方法
来源:互联网 发布:淘宝logo双十一 编辑:程序博客网 时间:2024/05/16 11:04
Wpf本身的方法如果想加载GIF图像实在是过于复杂,我们可以通过使用winform控件,减少复杂性
方法一:利用winform控件 System.Windows.Forms. PictureBox pb = new System.Windows.Forms.PictureBox() { Width = 200, Height = 150, SizeMode = PictureBoxSizeMode .CenterImage }; pb.Image = System.Drawing. Image.FromFile(@"C:\Users\zez\Desktop\201203161640295.gif" ); System.Windows.Forms.Integration. WindowsFormsHost wfh = new System.Windows.Forms.Integration.WindowsFormsHost (); wfh.Child = pb; grid.Children.Add(wfh);注 :System.Windows.Forms.Integration命名空间在V3.0中,有时需要单独添加引用 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\...方法二:只能读取第一帧 BitmapImage img = new BitmapImage(); img.BeginInit(); img.UriSource = new Uri (@"C:\Users\zez\Desktop\201203161640295.gif"); img.DecodePixelWidth = 200; img.EndInit(); Border bor = new Border() { Width=300 ,Height=200 ,HorizontalAlignment= System.Windows.HorizontalAlignment .Left}; bor.Background = new ImageBrush (img); grid.Children.Add(bor);方法三:使用解码器 Uri myUri = new Uri("tulipfarm.bmp", UriKind.RelativeOrAbsolute);//(第二个参数指定Uri地址) GifBitmapDecoder decoder2 = new GifBitmapDecoder(myUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); 通过decoder2.Frames可以获取gif所有帧,然后存入集合,循环播放,
0 0
- 在Wpf中使用动态GIF图像的简单方法
- [WPF疑难]在WPF中显示动态GIF
- [WPF疑难]在WPF中显示动态GIF
- 在WPF中使用Emgu加载Image<,>图像的两种方法
- WPF页面元素中加入gif动画的方法
- WPF显示GIF图像
- 读取JPEG和GIF图像的简单方法
- WPF中图像模糊的处理方法
- RichView中插入动态Gif图像注意事项
- 在WPF中使用水晶报表for vs2010的方法
- vc显示jpg,gif图像简单方法
- vc显示jpg,gif图像简单方法
- vc显示jpg,gif图像简单方法
- vc显示jpg,gif图像简单方法
- 在Sliverlight中使用动态图片背景(gif),让你的图片动起来
- Fresco的简单使用支持gif动态图片
- 【续】WPF支持GIF的各种方法
- 在WPF中使用WinForm控件方法
- 南宁肛周脓肿怎么办
- linux下VI编辑器常用指令
- 南宁肛周脓肿的原因
- JSONModel解析数据成Model
- 南宁肛周脓肿怎么治
- 在Wpf中使用动态GIF图像的简单方法
- 南宁肛门长肛周脓肿
- 信号槽链接触发写销毁
- 自定义控件其实很简单1/2
- 大数据处理的架构逻辑
- 【Android开发】自定义ListView,使用通用适配器,并实现ListView上的每一项和每一项上的按钮等控件同时监听
- 南宁大便流了很多血
- cocos2d-x 中添加显示文字的三种方式 LabelTTF 、LabelBMFont 和 LabelAtlas - 冠军
- 8大排序算法图文讲解