teky 的 blog
在vck中学习,在vck中进步~
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345
公告

留言簿(11)

随笔档案

文章分类

文章档案

相册

Windows Mobile

我的好友

朋友创业,其路漫漫

搜索

最新评论

阅读排行榜

评论排行榜

 
VC知识库BLOG   首页  新随笔  联系  聚合  登录 
  随笔-30 文章-17 评论-93 Trackbacks-4

用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 );
   } 

posted on 2006-11-07 17:23 teky 阅读(6718) 评论(12)  编辑 收藏
Comments
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    andson
    Posted @ 2007-03-21 10:47
    请问这几个文件在何处下载?
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    teky
    Posted @ 2007-03-23 09:55
    baidu下吧,如果找不到,留邮箱,我发给你也可以:)
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    周星星
    Posted @ 2007-04-17 16:07
    galford666@163.com
    谢谢
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    andy
    Posted @ 2007-07-17 22:20
    求上面的GIF类库,希望大哥也给我发一份,谢谢
    邮箱:xiaoxiao0366@163.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    香蕉
    Posted @ 2007-09-17 10:01
    求上面的GIF类库,希望大哥也给我发一份,谢谢 
    邮箱:fanjie51@1yahoo.com.cn
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    香蕉
    Posted @ 2007-09-17 10:01
    不胜感激
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    fubeidong
    Posted @ 2007-10-29 23:11
    正需要,能否发一份fubeidong@163.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    owen
    Posted @ 2007-11-01 12:55
    你好,我现在也在研究这个功能
    能发给我一份gif编码封装类库吗?
    谢谢了
    stormwen@126.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    tubo
    Posted @ 2007-11-02 09:30
    能不能给我也发一份,谢谢
    tubomag@weitown.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    mars
    Posted @ 2008-04-01 11:03
    谢谢!也给我发一份吧!
    154121761@qq.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    loning
    Posted @ 2008-04-23 11:18
    找不到啊,能发一份么?
    aloning@gmail.com
  • # re: AnimatedGifEncoder.cs GifDecoder.cs
    www.zqzj.net
    Posted @ 2008-06-16 15:00
    大哥,有个问题就是,分解的图片再次 合成的时候,会出现很奇怪的现象
    第一帧是完整的 图像
    后面的帧 就是透明的

    合成后就变成了 第一帧 可以看到全部图片
    后面帧 就变成了 透明的,然后 会有背景色...
标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]