html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

.NET中如何分解和合成Gif图像_.NET教程_编程技术

[ ] 已经帮助:人解决问题

合成GIFnULHTML5中文学习网 - HTML5先行者学习网

  1. /* create Gif */ 
  2. //you should replace filepath  
  3. String [] imageFilePaths = new String[]{"c://01.png","c://02.png","c://03.png"};  
  4. String outputFilePath = "c://test.gif";  
  5. AnimatedGifEncoder e = new AnimatedGifEncoder();  
  6. e.Start( outputFilePath );  
  7. e.SetDelay(500);  
  8. //-1:no repeat,0:always repeat  
  9. e.SetRepeat(0);  
  10. for (int i = 0, count = imageFilePaths.Length; i < count; i++ )  
  11. {  
  12.     e.AddFrame( Image.FromFile( imageFilePaths[i] ) );  
  13. }  
  14. e.Finish();  
  15. /* extract Gif */ 
  16. string outputPath = "c://";  
  17. GifDecoder gifDecoder = new GifDecoder();  
  18. gifDecoder.Read( "c://test.gif" );  
  19. for ( int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++ )  
  20. {  
  21.     Image frame = gifDecoder.GetFrame( i ); // frame i  
  22.     frame.Save( outputPath + Guid.NewGuid().ToString() + ".png", ImageFormat.Png );  
  23. }  
  24.  

nULHTML5中文学习网 - HTML5先行者学习网
nULHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助