![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
Bitmap bmp = new Bitmap(100, 100
);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
Graphics g =
Graphics.FromImage(bmp);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
Font f = new Font("arial"
, 11f);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
Brush b = Brushes.Blue;
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
string txt = "Rotate text animation!"
;
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
SizeF sz =
g.MeasureString(txt, f);
g.Clear(Color.WhiteSmoke);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
g.DrawString(txt, f, b, 50-sz.Width/2, 50-sz.Height/2
);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
g.Flush();
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
//(The following code create a starting frame from bmp)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
GifImage.GifAnimation gif = new
GifImage.GifAnimation(bmp,
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
GifImage.GraphicControlExt.Default);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
//(Set this property otherwise the animation will not play circularly)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
gif.Application = GifImage.ApplicationExt.Default;
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
//(Use global color table only, set this option will greatly decrease the size of output file)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
gif.UseGlobalColorTableOnly = true;
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
for (int i = 1; i < 36; ++i)
![](https://caca.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
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);
![](https://caca.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
g.Flush();
//(Create a frame from bitmap)
gif.AddFrame(bmp);
}
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
f.Dispose();
g.Dispose();
bmp.Dispose();
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
FileStream fs = new FileStream(@"E:\vmlinux\GifImage.gif", FileMode.Create);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
//(Write animation to GifImage.gif)
gif.Save(fs);
![](https://caca.cnblogs.com/Images/OutliningIndicators/None.gif)
fs.Close;