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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

TakeSnapShot function

Post Reply
asparagas
Posts: 24
Joined: Sun Nov 24, 2019 11:36 pm

TakeSnapShot function

Post 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...
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapShot function

Post 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
asparagas
Posts: 24
Joined: Sun Nov 24, 2019 11:36 pm

Re: TakeSnapShot function

Post by asparagas »

These functions save the image to disk!

How can I transfer the screenshot to a bitmap or stream?
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapShot function

Post 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
Post Reply