uses
Androidapi.JNI.GraphicsContentViewText,
FMX.Helpers.Android,
FMX.Surfaces;
//JBitmap转Bitmap
function JBitmapToBitmap(const AImage: JBitmap): TBitmap;
var
bitmapSurface :TBitmapSurface;
begin
bitmapSurface := TBitmapSurface.Create;
try
if JBitmapToSurface(AImage, bitmapSurface) then
begin
Result.Assign(bitmapSurface);
end;
finally
bitmapSurface.Free;
end;
end;
//Bitmap转JBitmap
function BitmapToJBitmap(Bmp:TBitmap): JBitmap;
var
mBitmap: JBitmap;
Surface: TBitmapSurface;
begin
Surface := TBitmapSurface.Create;
Surface.Assign(bmp);
mBitmap := TJBitmap.JavaClass.createBitmap(Bmp.Width, Bmp.Height, TJBitmap_Config.JavaClass.ARGB_8888);
if SurfaceToJBitmap(Surface, mBitmap) then
Result := mBitmap;
end;
Androidapi.JNI.GraphicsContentViewText,
FMX.Helpers.Android,
FMX.Surfaces;
//JBitmap转Bitmap
function JBitmapToBitmap(const AImage: JBitmap): TBitmap;
var
bitmapSurface :TBitmapSurface;
begin
bitmapSurface := TBitmapSurface.Create;
try
if JBitmapToSurface(AImage, bitmapSurface) then
begin
Result.Assign(bitmapSurface);
end;
finally
bitmapSurface.Free;
end;
end;
//Bitmap转JBitmap
function BitmapToJBitmap(Bmp:TBitmap): JBitmap;
var
mBitmap: JBitmap;
Surface: TBitmapSurface;
begin
Surface := TBitmapSurface.Create;
Surface.Assign(bmp);
mBitmap := TJBitmap.JavaClass.createBitmap(Bmp.Width, Bmp.Height, TJBitmap_Config.JavaClass.ARGB_8888);
if SurfaceToJBitmap(Surface, mBitmap) then
Result := mBitmap;
end;
本文介绍如何在Java和Delphi中实现Bitmap之间的相互转换。通过提供的代码示例,展示了如何将Java Bitmap对象转换为Delphi TBitmap对象,反之亦然。这对于跨平台应用程序开发特别有用。
2413

被折叠的 条评论
为什么被折叠?



