Frequently Asked Component Specific Questions
Options |
|
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>

TMS FMX WebGMapsTaking a screenshot in Android
The code below takes a screenshot of an instance of TTMSFMXWebGmaps and saves it to a file:
units
AndroidApi.JNI.Embarcadero, AndroidApi.JNI.GraphicsContentViewText, AndroidApi.JNI.JavaTypes, AndroidApi.Helpers, FMX.Objects, IOUtils
var
web: JWebBrowser;
pic: JPicture;
bmp: JBitmap;
c: JCanvas;
fos: JFileOutputStream;
fn: string;
begin
fn := TPath.GetDocumentsPath + PathDelim + ''sample.jpg'';
web := TJWebBrowser.Wrap(TMSFMXWebGMaps1.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;
end;