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

Create Image From Stream

P: n/a
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.
Mar 30 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

"John Daly" <Jo******@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
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.

Mar 30 '06 #2

P: n/a
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?

"Kevin Spencer" wrote:
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.

"John Daly" <Jo******@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
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.


Mar 30 '06 #3

P: n/a
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.

"John Daly" <Jo******@discussions.microsoft.com> wrote in message
news:A4**********************************@microsof t.com...
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?

"Kevin Spencer" wrote:
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.

"John Daly" <Jo******@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
> 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.


Mar 30 '06 #4

P: n/a

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.

Mar 31 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.