--RESOLVED-- How to dispose a GifEncoder ?
Hello guys... I am working on a program, that will pick 6 JPG files, and turn them into a animated GIF...
IT WORKS !!!
The only problem is, that, untill I close the WINDOWS FORMS, the .GIF file stays in use...
I need the .GIF file outputed, to be released as soon as it is done.
Please help..
Thanks guys.
string _picture1 ="c:\\C1.jpg";
string _picture2 = "c:\\C2.jpg";
string _picture3 = "c:\\C3.jpg";
string _picture4 = "c:\\C4.jpg";
string _picture5 = "c:\\C5.jpg";
string _picture6 = "c:\\C6.jpg";
try
{
String[] imageFilePaths = new String[] { _picture1, _picture2, _picture3, _picture4, _picture5,_picture6 };
// String[] imageFilePaths = new String[] { _picture1, _picture2};
String outputFilePath = "c:\\slides\\" + TB_slideid.Text + ".gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start(outputFilePath);
e.SetDelay(3000);
//-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();
/* extract Gif */
string outputPath = "c:\\slides";
GifDecoder gifDecoder = new GifDecoder();
gifDecoder.Read("c:\\slides\\" + TB_slideid.Text + ".gif");
for (int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++)
{
Image frame = gifDecoder.GetFrame(i); // frame i
frame.Save(outputPath + Guid.NewGuid().ToString() + ".png", ImageFormat.Png);
}
}