"Generic Error" in GDI+when saving a bitmap

slantz

Active member
Joined
Dec 12, 2003
Messages
37
Im trying to save the contents of a Bitmap object to a MemoryStream object. This works fine when I run it under Visual Studio, but if I just double-click on the .exe, I get the following error:

----------------------------
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
----------------------------

Heres my code:
----------------------------
Bitmap __tempBitmap = new Bitmap(width, height, __tempBitmapData.Stride, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, __tempBitmapData.Scan0);
__loadedFileBitmap.UnlockBits(__tempBitmapData);

__tempBitmap.Palette=__tempPalette;

Stream __tempStream = new MemoryStream();

__tempBitmap.Save(__tempStream, ImageFormat.Bmp);
----------------------------

The __tempBitmap.Save line is where it chokes.

Any help would be appreciated.

-Hiro_Antagonist
 
Back
Top