473,902 Members | 3,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10518
Use the Image.FromStrea m 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******@discu ssions.microsof t.com> wrote in message
news:52******** *************** ***********@mic rosoft.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(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
'create the web request
Dim wr As WebRequest =
WebRequest.Crea te("http://localhost/eventcalendar/calHome.aspx")

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

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

The last line where I am using Image.FromStrea m 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.FromStrea m 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******@discu ssions.microsof t.com> wrote in message
news:52******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.com> wrote in message
news:A4******** *************** ***********@mic rosoft.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(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
'create the web request
Dim wr As WebRequest =
WebRequest.Crea te("http://localhost/eventcalendar/calHome.aspx")

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

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

The last line where I am using Image.FromStrea m 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.FromStrea m 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******@discu ssions.microsof t.com> wrote in message
news:52******** *************** ***********@mic rosoft.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
4421
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 image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
6
3040
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 site. For instance, if the site is http://www.foobar.com, then /MyPictures/pic.jpg would be fully qualified by http://www.foobar.com/MyPictures/pic.jpg. Presumably there is a way to get the fully qualified path by giving the relative path.
9
8793
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 OleDbCommand("ImageBlobUpdate", dataConnection) Command.CommandType = CommandType.StoredProcedure)
3
2684
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 websites so I have to check if the image returned is fine or not. This is not that problematic, I can read the headers and understand if it is a jpg or a gif (the error one). The problem that I have is that sometimes although they have the...
8
2242
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 small example to do it? thx a lot men :)
2
4143
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: http://www.pythonware.com/library/pil/handbook/introduction.htm but it looks like it is something I will need to install - I'd like to be able to pass my script around to people without them needing any
3
4662
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 downloading. The threads that do the downloading trigger an event every 32K (the size of the chunks I receive), at which point the images are drawn in the Preview page. To create the images, I create a memory stream from the data and then use...
11
5401
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, fGetPerformanceGrade(SalesPersonID as Long) as String to retrieve that salesperson's grade (e.g. A+, A, A-, B+, B... D). Also one other function, fGetMonthlySales(SalesPersonID as Long) as String to get their sales figure, e.g. "$87K". I want web visitors to be able to click...
0
11277
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9672
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6084
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4305
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3323
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.