Web でこのコードを見つけましたが、FMX.Bitmap にはスキャンラインがありません。VCL.TBitmap を FMX.Bitmap に何らかの方法でコピーまたは描画することは可能ですか?
{$IFDEF MSWINDOWS}
type
TBitmap = FMX.Types.TBitmap;
TVclBitmap = Vcl.Graphics.TBitmap;
procedure TakeScreenshot(Dest: FMX.Types.TBitmap);
var
DC: HDC;
Size: TPointF;
VCLBitmap: TVclBitmap;
Y: Integer;
begin
VCLBitmap := nil;
//Size := FMX.Platform.IFMXScreenService.GetScreenSize;
DC := GetDC(0);
try
VCLBitmap := TVclBitmap.Create;
VCLBitmap.PixelFormat := pf32bit;
VCLBitmap.SetSize(Trunc(Size.X), Trunc(Size.Y));
BitBlt(VCLBitmap.Canvas.Handle, 0, 0, VCLBitmap.Width, VCLBitmap.Height,
DC, 0, 0, SRCCOPY);
Dest.SetSize(VCLBitmap.Width, VCLBitmap.Height);
{ The format of a FMX bitmap and a 32 bit VCL bitmap is the same, so just
copy the scanlines. - not true- FMX bitmap does not have ScanLine? }
for Y := Dest.Height - 1 downto 0 do
Move(VCLBitmap.ScanLine[Y]^, Dest.ScanLine[Y]^, Dest.Width * 4);
{Dest.Canvas.DrawBitmap(); Not possible to assign or draw}
finally
ReleaseDC(0, DC);
VCLBitmap.Free;
end;
end;
{$ENDIF}