I would like to show thumbnails of external websites that I link to when the user mouses over the links, similar to how snap.com does this. How can I accomplish the same thing?
+1
A:
Try System.Windows.Forms.WebBrowser. Like this:
void GetWebImage()
{
WebBrowser browser = new WebBrowser();
browser.Size = new Size(200, 150);
browser.ScrollBarsEnabled = false;
browser.Navigate("http://www.stackoverflow.com");
while (browser.ReadyState != WebBrowserReadyState.Complete)
{
// release temporary e.g. some threading resources ...
}
Bitmap bitmap = new Bitmap(200, 150);
browser.DrawToBitmap(bitmap, new Rectangle(browser.Location.X, browser.Location.Y, browser.Width, browser.Height));
}
and run it in STA thread:
Thread threas = new Thread(new ThreadStart(GetWebImage));
threas.SetApartmentState(ApartmentState.STA);
threas.Start();
then you can save the Bitmap to filesystem or you can use that code in Http Handler and with easy javascript code shows it after some mouse event..
Jan Remunda
2009-09-09 18:04:33