Page 1 of 1

Re: Howto save image into file.

Posted: Mon May 27, 2019 12:41 pm
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.

Re: Howto save image into file.

Posted: Tue May 28, 2019 7:33 am
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.