2012-07-05 73 views
0

如何从GeckoFX浏览器中的页面获取图像?如何在GeckoFX浏览器中下载图片?

我知道我可以简单地获取'src'属性的值,然后使用WebClient来下载文件,但我需要从浏览器中获取它,否则图片将在下次下载时更改。

回答

1

但是你可以把这个代码转换成等上下文菜单条时,图像是右键单击:

if(geckoWebBrowser1.CopyImageContents())//if image contents can be copied... 
{ 
    System.Drawing.Image img = Clipboard.GetImage();//copy image into variable 

    //here you can use a folder browser dialog to locate path manualy 
    img.Save(Application.StartupPath + "tempImg.jpg");//will save image to path 

    //last two lines is optional and can open same image in default image preview program 
    string fak = Application.StartupPath + "tempImg.jpg"; 
    System.Diagnostics.Process.Start(fak); 
}