4dots Software
CODE HELP BLOG
int iwidth=300;
int iheight=300;
Bitmap bmp=new Bitmap(iwidth,iheight);
using (Graphics g=Graphics.FromImage(bmp))
{
// drawing stuff
}
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.LightGray);
g.DrawLine(Pens.Black, 0, 0, 300, 300);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawString("hello world", this.Font, Brushes.Black, 50f, 50f);
}
// image's filepath
string filepath=@"c:\images\myimage.png";
Bitmap bmp = new Bitmap(filepath);
using (Graphics g = Graphics.FromImage(bmp))
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawString("hello world", this.Font, Brushes.Black, 50f, 50f);
}
// new image filepath
string newfilepath=@"c:\images\myimagenew.png";
// we save the bitmap as an PNG image
bmp.Save(newfilepath,System.Drawing.Imaging.ImageFormat.Png);