2

I am trying to extract image from c# webbrowser control, and return byte array of the same, i have managed to extract image, buy unable to get byte array of the same.

How do i get IHTMLImgElement to byte[], cannot find good examples on google, please any suggestions ?

Thank you.

Milan Solanki
  • 1,207
  • 4
  • 25
  • 48

1 Answers1

2

How about just downloading the original?

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

You may need to convert src to a fullly qualified URL which you can probably get from the webBrowser.Url (?) property.

Michael Kennedy
  • 3,202
  • 2
  • 25
  • 34