Search code examples
.netimagegifimage-generation

How can I generate GIF images in .NET?


Is there a .NET library I can use to programmatically generate my own GIF images?

At a minimum I'd like to build it pixel-by-pixel. Better would be support for text and shapes.

Here's an example of what I'm trying to do. I mocked this up in Photoshop…

Number line graphic http://img143.imageshack.us/img143/5458/dollarlineot9.gif

What do you recommend?


Solution

  • Bitmap bmp = new Bitmap(xSize, ySize, PixelFormat.Format32bppArgb);
    using (Graphics g = Graphics.FromImage(bmp)) {
      // Use g and/or bmp to set pixels, draw lines, show text, etc...
    }
    bmp.Save(filename, ImageFormat.Gif);
    

    Job done