2011-05-20 71 views
2

我想从c#webbrowser控件中提取图像,并返回相同的字节数组,我设法提取图像,购买无法获得相同的字节数组。IHTMLImgElement to byte []

如何将IHTMLImgElement转换为byte [],无法在google上找到好的示例,请提供任何建议?

谢谢。

+2

请参阅http://stackoverflow.com/questions/5899417/saving-images-from-a-webbrowser-control – 2011-05-20 10:04:24

回答

2

如何下载原件?

string imgSrc = htmlImgElement.src; 
WebClient web = new WebClient(); 
byte[] imageData = web.DownloadData(imgSrc); 

您可能需要将src转换为您可能从webBrowser.Url(?)属性获取的完全合格的URL。