Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / March 2006

Tip: Looking for answers? Try searching our database.

Create Image From Stream

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Daly - 30 Mar 2006 02:01 GMT
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.
Kevin Spencer - 30 Mar 2006 13:07 GMT
Use the Image.FromStream method.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

> Does anyone know how to create an image (JPEG) from an HTTPResponse
> object? I
[quoted text clipped - 6 lines]
> Any help will be much appreciated. If anyone knows of any articles, etc
> please forward. Thanks.
John Daly - 30 Mar 2006 15:06 GMT
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?

> Use the Image.FromStream method.
>
[quoted text clipped - 8 lines]
> > Any help will be much appreciated. If anyone knows of any articles, etc
> > please forward. Thanks.
Kevin Spencer - 30 Mar 2006 17:53 GMT
It doesn't look to me like you're requesting an image. It looks like you're
requesting an ASPX page.

Signature

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
[quoted text clipped - 46 lines]
>> > Any help will be much appreciated. If anyone knows of any articles, etc
>> > please forward. Thanks.
alantolan@users.com - 31 Mar 2006 01:39 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.