473,386 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Create Image From Stream

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
4 10476
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
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
6
by: David W. Simmonds | last post by:
I know that I can create an Image object by using a path like C:\MyPictures\pic.jpg, but how can I create an Image object by using a path like /MyPictures/pic.jpg where the path is relative to the...
9
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New...
3
by: christiang | last post by:
Hi guys, I'd like to use Alexia thumbnail service. It's an interesting service, you pass an url to its cgi and you get a thumbnail of that url. Of course they don't have the screenshots of all the...
8
by: paraidy | last post by:
Hi all, as from object i need to read all byte from a file example c: \myphoto.jpg and recreate the file with another name to another directory c:\photo\recreatedphoto.jpg can someone write a...
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
3
by: pedrito | last post by:
I've got an app that downloads images off the internet using anywhere from 1-20 threads concurrently (though generally around 4 threads). I have a preview page that shows the images as they're...
11
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.