Click here to Skip to main content
13,799,269 members
Click here to Skip to main content
Add your own
alternative version


116 bookmarked
Posted 1 Sep 2005
Licenced CPOL

NGif, Animated GIF Encoder for .NET

, 1 Sep 2005
Rate this:
Please Sign up or sign in to vote.
Create animated GIF images using C#.

Sample Image - NGif.gif


Because .NET Framework can't create animated GIF images, NGif provides a way to create GIF animations in the .NET framework. It can create an animated GIF from several images and extract images from an animated GIF.

Using the code

/* create Gif */
//you should replace filepath
String [] imageFilePaths = new String[]{"c:\\01.png","c:\\02.png","c:\\03.png"}; 
String outputFilePath = "c:\\test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start( outputFilePath );
//-1:no repeat,0:always repeat
for (int i = 0, count = imageFilePaths.Length; i < count; i++ ) 
 e.AddFrame( Image.FromFile( imageFilePaths[i] ) );
/* extract 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 ); // frame i
 frame.Save( outputPath + Guid.NewGuid().ToString() 
                       + ".png", ImageFormat.Png );

Points of Interest

Use Stream to replace BinaryWriter when you write a fixed-byte structured binary file.


  • 31 Aug 2005: Draft.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

China China
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralBug: loopcount should be initialized at -1 Pin
dB.19-Feb-07 12:36
memberdB.19-Feb-07 12:36 
GeneralResizing an animated GIF Pin
dB.19-Feb-07 12:32
memberdB.19-Feb-07 12:32 
GeneralAccess to the path "c:\test.gif" is denied. Pin
saikatchoudhury20-Dec-06 21:43
membersaikatchoudhury20-Dec-06 21:43 
QuestionRelease as open source project? PinPopular
jongalloway16-Aug-06 12:33
memberjongalloway16-Aug-06 12:33 
General[Message Deleted] Pin
Damian Wood2-Jul-06 4:35
memberDamian Wood2-Jul-06 4:35 
GeneralRe: Solution for last 2 pixels of a frame being white Pin
BenBearChen24-Aug-06 19:10
memberBenBearChen24-Aug-06 19:10 
GeneralAnother Solution ! be tested! Pin
tianlupan224-Aug-06 22:31
membertianlupan224-Aug-06 22:31 
GeneralBUG! Last pixel (bottom-right) always white! (+) Pin
dtrofimov25-Feb-06 10:57
memberdtrofimov25-Feb-06 10:57 
GeneralRe: BUG! Last pixel (bottom-right) always white! (+) Pin
morhost28-Feb-12 5:45
membermorhost28-Feb-12 5:45 
QuestionBottom Right Corner Problem? Pin
RipplingCreek4-Feb-06 9:07
memberRipplingCreek4-Feb-06 9:07 
GeneralAdded output to a MemoryStream PinPopular
tgiphil1-Sep-05 23:59
membertgiphil1-Sep-05 23:59 
GeneralRe: Added output to a MemoryStream Pin
merto22-Jan-06 9:47
membermerto22-Jan-06 9:47 
GeneralRe: Added output to a MemoryStream Pin
ssh59110-Dec-06 21:21
memberssh59110-Dec-06 21:21 
GeneralRe: Added output to a MemoryStream Pin
dB.19-Feb-07 12:33
memberdB.19-Feb-07 12:33 
GeneralSuggestions Pin
The_Mega_ZZTer1-Sep-05 18:46
memberThe_Mega_ZZTer1-Sep-05 18:46 
QuestionRe: Suggestions Pin
ammarmujeeb30-Jan-06 3:10
memberammarmujeeb30-Jan-06 3:10 
AnswerRe: Suggestions Pin
tianlupan214-Aug-06 6:45
membertianlupan214-Aug-06 6:45 
AnswerRe: Suggestions Pin
pedro.pandre17-Aug-06 2:56
memberpedro.pandre17-Aug-06 2:56 
GeneralRe: Suggestions Pin
pedro.pandre17-Aug-06 3:03
memberpedro.pandre17-Aug-06 3:03 
AnswerRe: Suggestions [modified] Pin
Phoenixillusion3-Mar-07 0:08
memberPhoenixillusion3-Mar-07 0:08 
GeneralRe: Suggestions Pin
Jim Hunt15-Jun-07 9:22
memberJim Hunt15-Jun-07 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181207.3 | Last Updated 1 Sep 2005
Article Copyright 2005 by gOODiDEA.NET
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid