User539648229 posted
Hi
I create a Bitmap and when try to save it in png format there is an error. It says:
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
There is no problem saving in gif or jpeg formats.
and my code:
// Create a new Bitmap object, 50 x 50 pixels in size
Image canvas = new Bitmap(50, 50);
// create an object that will do the drawing operations
Graphics artist = Graphics.FromImage(canvas);
// draw a few shapes on the canvas picture
artist.Clear(Color.Lime);
artist.FillEllipse(Brushes.Red, 3, 30, 30, 30);
artist.DrawBezier(new Pen(Color.Blue, 3), 0, 0, 40, 15, 10, 35, 50, 50);
// return the picture
canvas.Save(Response.OutputStream, ImageFormat.Png);
// now the drawing is done, we can discard the artist object
artist.Dispose();
// also the Bitmap
canvas.Dispose();
Help please
Thanks