Groups | Blog | Home
all groups > dotnet drawing api > february 2004 >

dotnet drawing api : Screen Scrape to thumbnail image????



Curtis Tammany
2/5/2004 2:50:47 PM
Hi-
Does anyone know how to take a screen scrape of a web page and convert =
it to a thumbnail image?=20
I don't know where to start.

Thanks in advance,

Justin Rogers
2/6/2004 3:47:59 PM
This is going to be far harder than you might think. I'd first =
investigate third party libraries that do this. Then if you don't find =
anything you'd like:

1. Learn how to use the WebBrowser control.
2. With the document loaded into the WebBrowser control get the DC or =
device context
3. Create an offscreen surface of the thumbnailed size.
4. Call StretchBlt to go from the WebBrowser DC to the thumbnail =
surface.


--=20
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
[quoted text, click to view]
Hi-
Does anyone know how to take a screen scrape of a web page and convert =
it to a thumbnail image?=20
I don't know where to start.

Thanks in advance,

Curtis Tammany
2/10/2004 10:52:38 AM
It would seem something like this would work:


Dim objWebClient as New WebClient()
Const strURL as String =3D "http://www.cnn.com/"
Dim HTMLStream as Stream =3D objWebClient.OpenRead(strURL)
dim imgOutput =3D New Bitmap(HTMLStream) =20
dim g as graphics =3D graphics.fromimage(imgOutput) ' create a New =
graphic object from the above bmp =20
response.contenttype=3D"image/gif" =20
imgOutput.save(response.outputstream, imageformat.gif) ' output to =
the user =20
g.dispose() =20
imgOutput.dispose()
HTMLStream.Close()


but I get an error creating the bitmap (invalid parameter used).

I think I'm close but not sure what I'm doing wrong.

Curtis
[quoted text, click to view]
This is going to be far harder than you might think. I'd first =
investigate third party libraries that do this. Then if you don't find =
anything you'd like:

1. Learn how to use the WebBrowser control.
2. With the document loaded into the WebBrowser control get the DC or =
device context
3. Create an offscreen surface of the thumbnailed size.
4. Call StretchBlt to go from the WebBrowser DC to the thumbnail =
surface.


--=20
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
[quoted text, click to view]
Hi-
Does anyone know how to take a screen scrape of a web page and =
convert it to a thumbnail image?=20
I don't know where to start.

Thanks in advance,

Justin Rogers
2/10/2004 2:47:57 PM
You can't create a bitmap from text. You have to use IE and the =
WebBrowser control it provides through
Interop in order to load some HTML and display it offscreen. Once the =
display is rendered you can get the
device context of the WebBrowser control and StretchBlt it to your =
thumbnail surface. Almost 100% of this
process is going to be though RCWs (runtime callable wrappers) and =
PInvoke. There is not a good managed
solution for this.


--=20
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

[quoted text, click to view]
It would seem something like this would work:


Dim objWebClient as New WebClient()
Const strURL as String =3D "http://www.cnn.com/"
Dim HTMLStream as Stream =3D objWebClient.OpenRead(strURL)
dim imgOutput =3D New Bitmap(HTMLStream) =20
dim g as graphics =3D graphics.fromimage(imgOutput) ' create a New =
graphic object from the above bmp =20
response.contenttype=3D"image/gif" =20
imgOutput.save(response.outputstream, imageformat.gif) ' output to =
the user =20
g.dispose() =20
imgOutput.dispose()
HTMLStream.Close()


but I get an error creating the bitmap (invalid parameter used).

I think I'm close but not sure what I'm doing wrong.

Curtis
[quoted text, click to view]
This is going to be far harder than you might think. I'd first =
investigate third party libraries that do this. Then if you don't find =
anything you'd like:

1. Learn how to use the WebBrowser control.
2. With the document loaded into the WebBrowser control get the DC =
or device context
3. Create an offscreen surface of the thumbnailed size.
4. Call StretchBlt to go from the WebBrowser DC to the thumbnail =
surface.


--=20
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
[quoted text, click to view]
Hi-
Does anyone know how to take a screen scrape of a web page and =
convert it to a thumbnail image?=20
I don't know where to start.

Thanks in advance,

AddThis Social Bookmark Button