Copy Code code as follows:
public static Bitmap Watermarkwithtext (System.Drawing.Bitmap origialgif, string
Text,string FilePath)
{
For storing hardwood
List<frame> frames = new
List<frame> ();
If not a GIF file, return directly to the original image
if (origialGif.RawFormat.Guid
!= System.Drawing.Imaging.ImageFormat.Gif.Guid)
{
return origialgif;
}
If the image is a GIF file
foreach (GUID GUID in
Origialgif.framedimensionslist)
{
System.Drawing.Imaging.FrameDimension
Framedimension = new System.Drawing.Imaging.FrameDimension (GUID);
Int
Framecount = Origialgif.getframecount (framedimension);
for (int i = 0; i
< Framecount; i++)
{
if (Origialgif.selectactiveframe (Framedimension,
i) = = 0)
{
int delay =
Convert.ToInt32 (Origialgif.getpropertyitem (20736). Value.getvalue (i));
Image
img = Image.fromhbitmap (Origialgif.gethbitmap ());
Font font = new Font (NEW
FontFamily ("Song Body"), 35.0f,fontstyle.bold);
Graphics g =
Graphics.fromimage (IMG);
g.DrawString (text, font, Brushes.blanchedalmond,
New PointF (10.0f, 10.0f));
Frame frame = new Frame (img, delay);
Frames. ADD (frame);
}
}
Gif.Components.AnimatedGifEncoder gif =
New Gif.Components.AnimatedGifEncoder ();
Gif. Start (FilePath);
Gif. Setdelay (100);
Gif. Setrepeat (0);
for (int i = 0; i <
Frames. Count; i++)
{
Gif. Addframe (Frames[i]. Image);
}
Gif. Finish ();
Try
{
Bitmap gifimg =
(Bitmap) Bitmap.fromfile (FilePath);
return gifimg;
}
Catch
{
return origialgif;
}
}
return origialgif;
}