I'm trying to draw text onto a bitmap, and the image is coming out black.
protected Bitmap DrawTextImage(string text, float fontsize, string fontname = "Helvetica")
{
string imagePath = @"C:\img.bmp";
string imagePathTest = @"C:\imgTest.bmp";
Font textFont = new Font(fontname, fontsize);
var size = TextRenderer.MeasureText(text, textFont);
Bitmap bmp = new Bitmap(size.Width, size.Height);
Graphics graphics = Graphics.FromImage(bmp);
SolidBrush brush = new SolidBrush(Color.Black);
graphics.DrawString(text, textFont, brush, size.Width, size.Height);
if(File.Exists(imagePathTest))
File.Delete(imagePathTest);
bmp.Save(imagePathTest, ImageFormat.Bmp);
For what it's worth, the image also needs to be eventually converted into a bitmap format for printing on a thermal printer, but I'm just focused on this part for the moment.
The arguments i'm using here are DrawTextImage(text, 36);