How to capture image from WebBrowser control?
- From: "StartPixel" <alex@xxxxxxxxxxxxx>
- Date: 15 Jun 2006 07:13:06 -0700
Hello all,
I need to develop a small application that browses webpages
automatically and saves the images found on those pages. Probably you
would say: iterate the HtmlElements collection, find the value of the
SRC attribute, load each image using its corresponding URL and then
save it.
That doesn't work unfortunately, because the images are generated
dynamically when requesting the webpage.
What I did is the following:
- Browse to the desired webpage in a WebBrowser control
- Hide all elements except the desired image
- Resize the WebBrowser to display the full image
I can't manage to capture the displayed image from the WebBrowser
control. My WebBrowser control is named wbBrowser
What I tried is the following:
Graphics g = wbBrowser.CreateGraphics();
Bitmap bmp = new Bitmap(width, height);
g.DrawImage(bmp, 1, 1, width, height);
bmp.Save("C:\\test_file.jpg",System.Drawing.Imaging.ImageFormat.get_Jpeg());
g.Dispose();
It does save the file, but it is completely blank. Its background color
is black and I see nothing of the 'captured' image in it. I also tried
to save as bitmap. It saves the file, also completely blank, but with a
grey background color.
File size is 9KB using either JPG or BMP format.
What am I doing wrong here?
If I'm correct, it should be possible to capture the displayed contents
of the WebBrowser control as a bitmap and save that to a file.
Any help would be greatly appreciated.
Thank you all very much in advance!
Regards,
Alex
.
- Follow-Ups:
- Re: How to capture image from WebBrowser control?
- From: Michael Phillips, Jr.
- Re: How to capture image from WebBrowser control?
- Prev by Date: Re: Performance & new Pen() / new Brush()
- Next by Date: Re: Performance & new Pen() / new Brush()
- Previous by thread: Performance & new Pen() / new Brush()
- Next by thread: Re: How to capture image from WebBrowser control?
- Index(es):
Relevant Pages
|