Hi, I have a problem with exporting an image created with Eto.Drawing. The following code creates a completely black or transparent image, trying with all available PixelFormat values
// Material texture
var img = new Eto.Drawing.Bitmap(canvasSize, canvasSize, Eto.Drawing.PixelFormat.Format24bppRgb);
var g = new Eto.Drawing.Graphics(img);
g.FillRectangle(Eto.Drawing.Brushes.Gainsboro, 0, 0, canvasSize, canvasSize);
img.Save(filename, Eto.Drawing.ImageFormat.Png);
You have to dispose of the Eto.Drawing.Graphics object before saving.
e.g.
// Material texture
var img = new Eto.Drawing.Bitmap(canvasSize, canvasSize, Eto.Drawing.PixelFormat.Format24bppRgb);
using (var g = new Eto.Drawing.Graphics(img))
{
g.FillRectangle(Eto.Drawing.Brushes.Gainsboro, 0, 0, canvasSize, canvasSize);
}
img.Save(filename, Eto.Drawing.ImageFormat.Png);
Hi @curtisw,
thank you for the reply, that worked!
It would be nice to have these kind of information written somewhere in the documentation or in the Wiki, expecially when the behaviour is different from WMI/WPF/WinForm.
Thanks for the feedback, I’ll add a note to the Graphics constructor when passing in a Bitmap that it needs to be disposed for the changes to be applied.