I am developing an Android app with Delphi 10.2 Tokyo as a developer tool. In an effort to print to a Zebra printer, I need to send an image as a JBitmap
. I can not find any light on the subject how to load that JBitmap
. I have a TBitmap
containing the picture. I just need to juggle it over to that JBitmap
.
Any input is appreciated.
Thanks in advance
uses
Androidapi.JNI.GraphicsContentViewText,
FMX.Graphics, FMX.Surfaces, FMX.Helpers.Android;
function BitmapToJBitmap(const ABitmap: TBitmap): JBitmap;
var
LSurface: TBitmapSurface;
begin
Result := TJBitmap.JavaClass.createBitmap(ABitmap.Width, ABitmap.Height, TJBitmap_Config.JavaClass.ARGB_8888);
LSurface := TBitmapSurface.Create;
try
LSurface.Assign(ABitmap);
SurfaceToJBitmap(LSurface, Result);
finally
LSurface.Free;
end;
end;