2011-05-20 75 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。