Bitmap bmp = new Bitmap (100,100 );
Graphics g = Graphics. FromImage (bmp );
Font f = new Font ("arial", 11f );
Brush B = Brushes. Blue;
String txt = "Rotate text animation! ";
SizeF sz = g. MeasureString (txt, f );
G. Clear (Color. WhiteSmoke );
G. DrawString (txt, f, B, 50-sz.Width/2, 50-sz.Height/2 );
G. Flush ();
// (The following code create a starting frame from bmp)
GifImage. GifAnimation gif = new GifImage. GifAnimation (bmp,
GifImage. GraphicControlExt. Default );
// (Set this property otherwise the animation will not play circularly)
Gif. Application = GifImage. ApplicationExt. Default;
// (Use global color table only, set this option will greatly decrease the size of output file)
Gif. UseGlobalColorTableOnly = true;
For (int I = 1; I <36; ++ I)
{
G. Clear (Color. WhiteSmoke );
G. TranslateTransform (50, 50 );
G. RotateTransform (10f * I );
G. DrawString (txt, f, B, sz. Width/-2, sz. Height/-2 );
G. ResetTransform ();
G. DrawString ("Hello", f, Brushes. Red,-50 + I * 4, 20 );
G. DrawString ("Yeah", f, Brushes. Orange, 60,-20 + I * 4 );
G. Flush ();
// (Create a frame from bitmap)
Gif. AddFrame (bmp );
}
F. Dispose ();
G. Dispose ();
Bmp. Dispose ();
FileStream fs = new FileStream (@ "E: vmlinuxGifImage.gif", FileMode. Create );
// (Write animation to GifImage.gif)
Gif. Save (fs );
Fs. Close;