hello
can you please give a full working example of webbrowser or htmltext makescreenshot to save jpg file.
thank you
Hi,
To save an image of the webbrowser you need to use the following code (assuming you are targetting Windows)
var
bmp: TBitmap;
begin
bmp := TMSFMXWebBrowser1.MakeScreenshot;
if Assigned(bmp) then
begin
bmp.SaveToFile('Image1.jpg');
bmp.Free;
end;
end;
Kind Regards,
Pieter
thank you for your code
my platform is android and ios, i tried your code , but i see the blank jpg file.
any suggestion?
Unfortunately for Android taking a screenshot is not possible, but for iOS you could take a look at the following sample:
Kind Regards,
Pieter
htmltext android and ios possible?
If you are referring to the TTMSFMXHTMLText then yes, if you are using HTML text inside the TTMSFMXWebBrowser then no, the TTMSFMXWebBrowser is based on the native webbrowser and doesn't respond to the makescreenshot functionality.
Kind Regards,
Pieter
i change your example with html text in TTMSFMXHTMLText
and then run makescreenshot function.
Result is black image.
Hi,
In Android you need to save to png instead.
Kind Regards,
Pieter
in TTMSFMXHTMLText , i changed jpg to png.
i see the error message:
"bitmap size too big"
Hi,
Which version of RAD Studio are you using? Please note that the MakeScreenShot functionality is a FireMonkey inherited function, but it could be possible that the control you wish to capture is too large.
Kind Regards,
Pieter
i see your example in the site:
TJWebView.Wrap(TMSFMXWebGMaps1.NativeBrowser).capturePicture;
is it possible for android?
Yes, this is the code that can be used for Android. The TTMSFMXWebBrowser has the same structure as the TTMSFMXWebGMaps
i need your help
at screenshot in android
i changed the code for web browser
fn := system.IOUtils.TPath.GetDocumentsPath + PathDelim + 'sample.jpg';
web := TJWebBrowser.Wrap(webread.NativeBrowser);
pic := web.capturePicture;
bmp := TJBitmap.JavaClass.createBitmap(pic.getWidth, pic.getHeight, TJBitmap_Config.JavaClass.ARGB_8888);
c := TJCanvas.JavaClass.init(bmp);
pic.draw(c);
fos := TJFileOutputStream.JavaClass.init(StringToJString(fn));
if Assigned(fos) then
begin
bmp.compress(TJBitmap_CompressFormat.JavaClass.JPEG, 100, fos);
fos.close;
end;
but program crash?
what is the running code?
thank you
hakan
Hi,
Can you perhaps debug to know on which line it crashes?
Kind Regards,
Pieter
pic := web.capturePicture;
sorry i want to help you more, but it is interesting i cant catch the detail error with "try - raise Exception"
it is very important for the project, take a screenshot of webbrowser at android and ios.
thank you
but i see that problem is at this line:
pic := web.capturePicture;
i created a blank new multidevice app in xe8.
one web browser and two buttons.
button1: navigate google.com
button2: screenshot code
it is working ....
but if i load webbrowser with long html text, it crash at:
pic := web.capturePicture;
i dont understand the difference and solution for that?
Please send us your sample so we can investigate the code that is crashing.
Kind Regards,
Pieter