By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,952 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,952 IT Pros & Developers. It's quick & easy.

Save picturebox's image to stream

P: n/a
I got the error
=================
An unhandled exception of typ
'System.Runtime.InteropServices.ExternalException' occurred i
system.drawing.dl

Additional information: A generic error occurred in GDI+
=================

the code like this

Image aImg = pictrebox1.Image
MemoryStream ms = new MemoryStream()
aImg.Save(ms,aImg.RawFormat)

Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The error probably comes from the fact that the image has no raw format.
save it as a bitmap, tiff or jpeg.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41

"Alexli" <an*******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
I got the error:
==================
An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.drawing.dll

Additional information: A generic error occurred in GDI+.
==================

the code like this:

Image aImg = pictrebox1.Image;
MemoryStream ms = new MemoryStream();
aImg.Save(ms,aImg.RawFormat);

Nov 16 '05 #2

P: n/a
I have tried bmp and jpeg, got same error
Nov 16 '05 #3

P: n/a
"Alexli" wrote :
I have tried bmp and jpeg, got same error


I tried your code and it worked for me.

Where does your Image come from ?
Have you tried with another picture ?
What happen if you try the same thing in a new project ?

--
Francois Beaussier
Fr******@3ie.org.remove
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.