Click here to Skip to main content
15,441,508 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
private byte[] GetDrawingPicture()
       {
           MemoryStream stream = new MemoryStream();

           picDrawingImage.Image.Save(stream, picDrawingImage .Image .RawFormat );
           return stream.GetBuffer();
       }

when we call this function error occur 'A generic error occurred in GDI+.' at line picDrawingImage.Image.Save(stream, picDrawingImage .Image .RawFormat );
plz help me to solve this problem
thank in advance
Posted

The second parameter is not accepted (picDrawingImage.Image.RawFormat).

This should be of System.Drawing.Imaging.ImageFormat. Have a look at this link for reference:
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat.aspx[^]

As side note: You might want to consider using MemoryStream.ToArray() instead of MemoryStream.GetBuffer(). Have a look at the remarks on this page: http://msdn.microsoft.com/en-us/library/system.io.memorystream.getbuffer[^]

Good luck!
 
Share this answer
 
Try converting it to a Bitmap first, then use the Bmp image format
{
MemoryStream stream = new MemoryStream();
Bitmap bmp = new BitMap(picDrawingImage.Image)

bmp.Save(stream, ImageFormat.Bmp );
return stream.GetBuffer();
}
 
Share this answer
 
This error usually occurs when the file permission is not set to the folder where the image is saved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900