Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Howto save image into file.

Post Reply
User avatar
salvadordf
Posts: 4047
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Howto save image into file.

Post by salvadordf »

Hi,

Run the MiniBrowser demo and click on the upper-right button with 3 horizontal lines. Then select the "Download Image..." option to download an image to a file.

MiniBrowser calls TChromium.DownloadImage and the image is received in the TChromium.OnDownloadImageFinished event.
User avatar
salvadordf
Posts: 4047
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Howto save image into file.

Post by salvadordf »

CEF (Chromium) has a different way to access the DOM. You can get the same results but in a different way.

In case of image elements it's a little easier because you have the TChromium.DownloadImage procedure that triggers the TChromium.OnDownloadImageFinished event.

TChromium.OnDownloadImageFinished has an "image" parameter and you can call image.GetAsBitmap, image.GetAsPng or image.GetAsJpeg to get the raw binary data that can be used with a TBitmap.LoadFromStream, TPNGImage.LoadFromStream or TJPEGImage.LoadFromStream. The MiniBrowser demo has the code to do that.

If you don't know the image URL then you can use the DOMVisitor, JSExtension or JSRTTIExtension demos to search the DOM and send the URL to the browser process.
Post Reply