Page 1 of 1

TakeSnapShot function

Posted: Thu Oct 03, 2024 8:26 am
by asparagas
Hello, I'm Fevzi from Turkey

TakeSnapShot function doesn't work in new versions (>128.4.9 onwards)!

I would be very happy if you could take care of it.

Best regards...

Re: TakeSnapShot function

Posted: Thu Oct 03, 2024 9:20 am
by salvadordf
Hi,

TChromiumCore.TakeSnapshot copies the DC to a TBitmap. This function only works on Windows with browsers without GPU acceleration.

It's recommended to use the "Page.captureScreenshot" DevTools method instead.

The MiniBrowser demo has all the code you need :
https://github.com/salvadordf/CEF4Delphi/blob/a7a1fd27ed7f32904340fae6c6ec94c1b679a4a4/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1593
https://github.com/salvadordf/CEF4Delphi/blob/a7a1fd27ed7f32904340fae6c6ec94c1b679a4a4/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1634
https://github.com/salvadordf/CEF4Delphi/blob/a7a1fd27ed7f32904340fae6c6ec94c1b679a4a4/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1711

Re: TakeSnapShot function

Posted: Thu Oct 03, 2024 12:09 pm
by asparagas
These functions save the image to disk!

How can I transfer the screenshot to a bitmap or stream?

Re: TakeSnapShot function

Posted: Thu Oct 03, 2024 12:46 pm
by salvadordf
The last link shows the code that decodes the image into a TBytes variable called "TempData".

Use TStream.WriteBuffer to copy the data to a new TStream :
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TStream.WriteBuffer