在 FMX 中加入多个图像?

Join Multiple Images IN FMX?

在 VCL 中,这是我如何从两张图片制作一张图片,同时在它们之间创建 space:

 procedure TForm2.Button1Click(Sender: TObject);
var
p1,p2:string;
b1,b2:TBitmap;
bitmap: TBitmap;
begin
 p1:='C:\Users\John\Desktop\p1.bmp';
 p2:='C:\Users\John\Desktop\p2.bmp';
 b1:=TBitmap.Create;
 b1.LoadFromFile(p1);
 b2:=TBitmap.Create;
 b2.LoadFromFile(p2);
  sBit:= TBitmap.Create;
  try
   sBit.Height:=b1.Height;
   sBit.Width:=b1.Width+5+b2.Width;
   sBit.Canvas.Draw(0,0,b1); //Drawing First Bitamp here
   sBit.Canvas.Draw(b1.Width + 5,0,b2);// Drawing Second one 
   Image1.Picture.Bitmap.Assign(sBit);
  finally
   sBit.FreeImage;
  end;
end; 

现在如何在 FMX 中绘制相同的内容?

编辑

使用 Bitmap.CopyFromBitmap 有效!!

 procedure process;
 var
  p1,p2: String;
  b1,b2,b3:TBitmaps;
  rect: TRect;
  begin
  //load both bitmaps to b1 and b2.
  rect.Left:=0;
  rect.Top:=0;
  rect.Width:=b1.Width;
  rect.Height:=b1.Height; 
  b3:= TBitmaps.Create;
  b3.Height:= b1.height;
  b3.widht:=b1.width;
  b3.CopyFromBitmap(b1,rect,0,0);
  b3.CopyFromBitmap(b2,rect,b1r.Width+5,0);
  Image1.Bitmap.Assign(b3);
end; 

在 VCL 中,您不能将 PNG 图像加载到 TBitmap 中,只能加载 BMP 图像。对于 b1b2,您必须使用 TPngImageTPngImage 可以 Draw()'n 到 VCL TCanvas.

不过 FMX 的 TBitmap 支持 PNG。

在 FMX 中,在这种情况下 Canvas.Draw() 相当于使用 TBitmap.CopyFromBitmap():

Copies a rectangular area from a specified bitmap to the current bitmap.

然后用Image1.Bitmap.Assign(sBit);将最后的TBitmap赋值给TImage(FMX中没有TPicture