I've download an image from the Internet and converted to a String (This is not changeable)
Dim Request As System.Net.WebRequest = _ System.Net.WebRequest.Create( _ "http://www.google.com/images/nav_logo.png") Dim WebResponse As System.Net.HttpWebResponse = _ DirectCast(Request.GetResponse(), System.Net.HttpWebResponse) Dim Stream As New System.IO.StreamReader( _ WebResponse.GetResponseStream, System.Text.Encoding.UTF8) Dim Text as String = Stream.ReadToEnd
How can I convert the String back to the Stream?
So I can use that stream to get the image.
Dim Image As New Drawing.Bitmap(WebResponse.GetResponseStream)
But now I've only the Text String, so I need something like this:
Dim Stream as Stream = ReadToStream(Text, System.Text.Encoding.UTF8) Dim Image As New Drawing.Bitmap(Stream)
This engine was primarily used for downloading web pages but I'm trying to use it for downloading images too.
The format of the string is UTF8, as given in the example code…
I've tried to use the
MemoryStream(Encoding.UTF8.GetBytes(Text)), but I got this error when loading the stream to the image:
A generic error occurred in GDI+.
What gets lost in the conversions?