static private Image GenerateNumberImage( Color backColor, Color foreColor, Color borderColor, int value, Size size, Font font = null) { // Create a blank image of the specified size Bitmap bmp = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); // Create a Graphics object for the image using ( Graphics g = Graphics.FromImage(bmp) ) { // Use anti-aliasing to smooth curves g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Rectangle rect = new Rectangle(Point.Empty, size); rect.Inflate(-2, -2); // Background using ( Brush brush = new SolidBrush(backColor) ) { g.FillEllipse(brush, rect); } // Border using ( Pen pen = new Pen(borderColor, 2f) ) { //rect.Inflate(-1, -1); g.DrawEllipse(pen, rect); } // Number using ( Brush brush = new SolidBrush(foreColor) ) { if ( font == null ) font = SystemFonts.DefaultFont; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(value.ToString(), font, brush, rect, sf ); } } return bmp; }