Create Image From Stream

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to create an image (JPEG) from an HTTPResponse object? I
am working on system that has a map pop up from our GIS department. I want
create an image at runtime from this popup and display that image on the main
page instead of opening a new window. This image will be a memory stream
only, but will need to be kept from page to page, and printer if required.

Any help will be much appreciated. If anyone knows of any articles, etc
please forward. Thanks.
 
Use the Image.FromStream method.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
Kevin,
Thanks for the reply. Maybe if I post some code you will have a better
understanding as to what I want to do.

CODE:
Imports System
Imports System.Net
Imports System.Drawing
Imports System.Drawing.Image
Imports System.IO

Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'create the web request
Dim wr As WebRequest =
WebRequest.Create("http://localhost/eventcalendar/calHome.aspx")

'get the response into a stream
Dim st As Stream = wr.GetResponse.GetResponseStream

'create the image
Dim bm As Image = Image.FromStream(st)
End Sub
End Class

The last line where I am using Image.FromStream is throughing an error
"Parameter is vot valid".

I am guesing that I have to get the data into a browser control, then copy
the contents of the browser to the clipboard and create my image that way. Is
it possible to do something like that?
 
It doesn't look to me like you're requesting an image. It looks like you're
requesting an ASPX page.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
You shouldn't have to display in the browser and copy to clipboard. It
is possible to create an image directly from the web stream as long as
the stream represents an image. I have done it before with a URL that
denoted an jpeg

Try placing a jpeg on the server and downloading it. If it works, then
the problem is the aspx.


hth,
Alan.
 
Back
Top