C
C#2y ago
Binto86

❔ Bitmap created from graphics appears to be all black

I have some kind of drawing board in winforms. User draws into panel with graphics and than i want to save the image into file. relevant parts of code are (canvas is the name of the panel the user is drawing on):
Graphics graphics;
Pen pen;
Bitmap bmp;

public Form1()
{
InitializeComponent();
graphics = canvas.CreateGraphics();
pen = new Pen(Color.Black, 35);
bmp = new Bitmap(28, 28, graphics);
}

private void btnSave_Click(object sender, EventArgs e)
{
var fileName = "digit.png";
bmp.Save(fileName,ImageFormat.Png);
}
Graphics graphics;
Pen pen;
Bitmap bmp;

public Form1()
{
InitializeComponent();
graphics = canvas.CreateGraphics();
pen = new Pen(Color.Black, 35);
bmp = new Bitmap(28, 28, graphics);
}

private void btnSave_Click(object sender, EventArgs e)
{
var fileName = "digit.png";
bmp.Save(fileName,ImageFormat.Png);
}
but the saved image is all black, any ideas why?
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.