int imageSize = 30;
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(imageSize, imageSize);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.Clear(System.Drawing.Color.Blue);
SolidBrush redSolidBrush = new SolidBrush(System.Drawing.Color.DarkViolet);
g.FillRectangle(redSolidBrush, 0, 0, imageSize, imageSize - 5);
Font drawFont = new Font("Ariel Black", 12, System.Drawing.FontStyle.Regular);
SolidBrush whiteSolidBrush = new SolidBrush(System.Drawing.Color.White);
string label = "100";
SizeF stringSize = g.MeasureString(label, drawFont);
float startX = (imageSize - stringSize.Width) / 2;
float startY = (imageSize - stringSize.Height) / 2 - 2.5f;
g.DrawString(label, drawFont, whiteSolidBrush, new PointF(startX, startY));
bitmap.MakeTransparent(System.Drawing.Color.Blue);
System.IO.Stream imageStream = new System.IO.MemoryStream();
bitmap.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.