delphi JBitmapBitmap互转转换

来源:互联网 发布:如何在淘宝上买发票啊 编辑:程序博客网 时间:2024/05/08 00:35
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;