teky 的 blog
在vck中学习,在vck中进步~
<2006年11月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
公告

留言簿(11)

随笔档案

文章分类

文章档案

相册

Windows Mobile

我的好友

朋友创业,其路漫漫

搜索

最新评论

阅读排行榜

评论排行榜

 
VC知识库BLOG   首页  新随笔  联系  聚合  登录 
  随笔-30 文章-17 评论-94 Trackbacks-4
2006年11月7日

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

发表于 2006-11-07 17:23 teky 阅读(6984) | 评论 (12)编辑 收藏