Help With Image Displaying

PutterPlace

Active member
Joined
Feb 18, 2008
Messages
37
Programming Experience
1-3
I am working on a small project which requires me to display an image on one of my forms from a given URL. My original solution was to get the image URL from the HTML src from the <img src=""> tags. However, that posed a problem because the image was a dynamic image. For example:

http://www.danasoft.com/sig/DarksSignature.jpg

The image is changed each time it is requested, so I can't display the page and then save the picture using the image URL because the displayed image won't be the same as the saved image.

My project requires that I load a particular HTML page into a WebBrowser control. Then I need to save this particular image into the application's directory exactly as it is displayed. I was thinking maybe there was a way that I could save this image from some sort of cache?



Any help would be greatly appreciated.
 
I think a screen capture is needed. I first tried to focus the image element and copy it via clipboard (either SendKeys or ExecCommand), and this worked just a few times, then no go!? Well try this, works for me:
VB.NET:
Dim r As Rectangle = Me.WebBrowser1.Document.Images(0).OffsetRectangle
Dim p As Point = Me.WebBrowser1.Parent.PointToScreen(Me.WebBrowser1.Location)
r.Offset(p)
Dim bmp As New Bitmap(r.Width, r.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(r.Location, Point.Empty, r.Size)
g.Dispose()
Me.PictureBox1.Image = bmp
 
Thanks, JohnH. I will try this out this afternoon when I have a little more time to work on this project. I will post back with my results. :)
 
Back
Top