AnimatedGifEncoder.cs GifDecoder.cs
来源:互联网 发布:网络平台贷款是否合法 编辑:程序博客网 时间:2024/04/30 12:29
用CF1真可怜,想要用bitmap.Save()把bitmap保存为gif格式都不让,还要用自己写的编码来实现,还好最近有了新发现,在网上找到一个比较好用的gif编码,解码C#封装类库,它由4个文件AnimatedGifEncoder.cs GifDecoder.cs LZWEncoder.cs NeuQuant.cs 组成.
加到工程里面,就可以象下面这样使用了,有兴趣可以试试.
使用例子:
/* 合成 Gif */
String [] imageFilePaths = new String[]{"d://Frame0.jpg","d://Frame1.jpg","d://Frame2.jpg"};
string outputFilePath = "c://test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start( outputFilePath );
//图片转换时间
e.SetDelay(50);
//1表示只动一次,0:表示循环,n:表示循环n次
e.SetRepeat(0);
for (int i = 0, count = imageFilePaths.Length; i < count; i++ )
{
e.AddFrame( Image.FromFile( imageFilePaths[i] ) );
//或者e.AddFrame(Bitmap对象);
}
e.Finish();
/* 分解 Gif */
string outputPath = "c://";
GifDecoder gifDecoder = new GifDecoder();
gifDecoder.Read( "c://test.gif" );
for ( int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++ )
{
Image frame = gifDecoder.GetFrame( i ); // 第i帧
frame.Save( "......//image.png",ImageFormat.Png );
}
加到工程里面,就可以象下面这样使用了,有兴趣可以试试.
使用例子:
/* 合成 Gif */
String [] imageFilePaths = new String[]{"d://Frame0.jpg","d://Frame1.jpg","d://Frame2.jpg"};
string outputFilePath = "c://test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start( outputFilePath );
//图片转换时间
e.SetDelay(50);
//1表示只动一次,0:表示循环,n:表示循环n次
e.SetRepeat(0);
for (int i = 0, count = imageFilePaths.Length; i < count; i++ )
{
e.AddFrame( Image.FromFile( imageFilePaths[i] ) );
//或者e.AddFrame(Bitmap对象);
}
e.Finish();
/* 分解 Gif */
string outputPath = "c://";
GifDecoder gifDecoder = new GifDecoder();
gifDecoder.Read( "c://test.gif" );
for ( int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++ )
{
Image frame = gifDecoder.GetFrame( i ); // 第i帧
frame.Save( "......//image.png",ImageFormat.Png );
}
- AnimatedGifEncoder.cs GifDecoder.cs
- CS..........................
- cs
- cs
- cs
- Cs
- cs
- cs
- cs
- CS
- cs
- cs,
- cs
- cs
- cs
- cs
- cs
- cs
- 数据库中如何分类、分组并总计SQL数据
- Windows mobile多窗口的模式中窗口之间切换显示的连续性
- CameraCaptureDialog
- vs.net快捷键
- 关于blog名
- AnimatedGifEncoder.cs GifDecoder.cs
- byte to string
- class size与align
- 设置smartphone桌面背景图片
- VC中数据类型之间的转换
- vc 生成dll注意问题
- 读取SQL时的float
- mysql中操作IP地址的函数
- java 超强日期处理 东西很多 希望能对大家有所帮助