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.

TakeSnapshot - Black screen

Post Reply
giovani.erthal
Posts: 12
Joined: Mon Nov 18, 2019 9:23 pm

TakeSnapshot - Black screen

Post by giovani.erthal »

I have the following code:

Code: Select all

APrint := TBitmap.Create;
try
    if CefWindowParent1.TakeSnapshot( APrint ) = True then
        APrint.SaveToFile( 'Test.bmp' );
finally
    if ( APrint <> nil ) and ( Assigned( APrint ) = True ) then
        APrint.Free;
end;
But the saved Bitmap is a black screen.

I am using Lazarus 2.0.6 64 Bit (CEF 78.2.9).

I already tried to disable hardware acceleration(GlobalCEFApp.EnableGPU := False), and the result is the same.

Does anyone know why this is happening?
giovani.erthal
Posts: 12
Joined: Mon Nov 18, 2019 9:23 pm

Re: TakeSnapshot - Black screen

Post by giovani.erthal »

I just tested the SimpleOSRBrowser demo, and on it, the page content is all black.

Image
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapshot - Black screen

Post by salvadordf »

Hi,

It's the first time I see that black screen in the SimpleOSRBrowser demo.

Download the official CEF sample application to see if google.com is shown correctly. Perhaps there's a hardware compatibility problem :
http://opensource.spotify.com/cefbuilds ... nt.tar.bz2

Please, update CEF4Delphi to the latest version in the development branch and install it in Lazarus :
https://github.com/salvadordf/CEF4Delphi

You will need to download the latest CEF binaries using the links in the "readme.md" file.
giovani.erthal
Posts: 12
Joined: Mon Nov 18, 2019 9:23 pm

Re: TakeSnapshot - Black screen

Post by giovani.erthal »

Upgrading the version, the OSR demo works perfectly.

However, the TakeSnapshot function continues to capture a black screen.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapshot - Black screen

Post by salvadordf »

Sorry for the delay.

I could finally reproduce this issue by running the demo in Windows 10. It works fine in Windows 7.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapshot - Black screen

Post by salvadordf »

I added an issue about this at GitHub :
https://github.com/salvadordf/CEF4Delphi/issues/248
giovani.erthal
Posts: 12
Joined: Mon Nov 18, 2019 9:23 pm

Re: TakeSnapshot - Black screen

Post by giovani.erthal »

Thank you very much for your attention, congratulations on the product and sorry for the delay.

I use Windows 10, did not have the opportunity to test on Windows 7.

I may be wrong, but I looked at the TakeSnapShot function code, and apparently it doesn't work if the application is minimized, is this correct?

Using Browser in OSR mode, is it possible to take a screenshot with the minimized application?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TakeSnapshot - Black screen

Post by salvadordf »

The SimpleOSRBrowser demo has some calls to TChromium.WasHidden, TChromium.SendFocusEvent, TChromium.WasResized when the form is hidden or is resized.

Download the latest CEF4Delphi release to avoid a known crash when the OSR browser is resized and try removing those calls when the form is being minimized.

If the browser thinks that it's always focused and visible you should be able to take snapshots.

Use this release to avoid issues :
https://github.com/salvadordf/CEF4Delph ... ses/latest
Post Reply