Need some help with a “generic GDI+ error”

I've been trying for hours to solve this problem, basically, I have a memory stream with PNG data that I need to convert to a bitmap, edit it, and convert back to PNG. The problem is, it throws an error as soon as I even try to save it into a new MemoryStream, so I can work with it.

using (var stream = new MemoryStream(FileBuffer)) { using (var bmp = new Bitmap(stream)) { bmp.Save(stream2, ImageFormat.Bmp); //error ///<conversion code here, I took it all out, and it still didn't work> } } 

Exception detail:

System.Runtime.InteropServices.ExternalException was unhandled by user code HResult=-2147467259 ErrorCode=-2147467259 Message=A generic error occurred in GDI+ Source=System.Drawing ErrorCode=-2147467259 

Any tips? I'm kinda lost here.

Edit: formatting

by Blokatt via /r/csharp

Leave a Reply