1
Answer

How to convert multiple .png files to gif to creat gif animation in c#?

jaypee bacol

jaypee bacol

14y
4.7k
1
I tried this code below and it worked. But the problem is that, the quality is not good, I can see some colors are not good. I want to create gif that has good quality of resolution.

* create Gif */
//you should replace filepath
String[] imageFilePaths = new String[] { @"c:\gif\1\1.png", @"c:\gif\2\2.png", @"c:\gif\3\3.png", @"c:\gif\4\4.png", @"c:\gif\5\5.png", @"c:\gif\6\6.png"};
String outputFilePath = "c:\\test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start( outputFilePath );
e.SetDelay(500);
//-1:no repeat,0:always repeat
e.SetRepeat(0);
for (int i = 0, count = imageFilePaths.Length; i < count; i++ )
{
e.AddFrame( Image.FromFile( imageFilePaths[i] ) );
}
e.Finish();

Please help me this is urgent

Answers (1)