Cómo tomar una captura de pantalla con FireMonkey (multiplataformas)
No he encontrado una función para obtener una captura de pantalla en FMX.Plataforma (de todos modos, en ningún otro lugar ...).
Con el VCL, hay muchas respuestas (stackoverflow, google, ...).
¿Pero cómo obtener una captura de pantalla en una imagen (mapa de bits o lo que sea) para Windows y Mac OS X?
Saludos,
W.
Actualizar: losenlace desde Tipiweb Da una buena solución para OS X.
Con respecto a la parte de Windows: he codificado esto, pero no me gusta usar el VCL y un Stream para lograrlo ... ¿Alguna sugerencia mejor, comentarios?
Gracias.
W.
<code>uses ..., FMX.Types, Winapi.Windows, Vcl.Graphics; ... function DesktopLeft: Integer; begin Result := GetSystemMetrics(SM_XVIRTUALSCREEN); end; function DesktopWidth: Integer; begin Result := GetSystemMetrics(SM_CXVIRTUALSCREEN); end; function DesktopTop: Integer; begin Result := GetSystemMetrics(SM_YVIRTUALSCREEN); end; function DesktopHeight: Integer; begin Result := GetSystemMetrics(SM_CYVIRTUALSCREEN); end; procedure GetScreenShot(var dest: FMX.Types.TBitmap); var cVCL : Vcl.Graphics.TCanvas; bmpVCL: Vcl.Graphics.TBitmap; msBmp : TMemoryStream; begin bmpVCL := Vcl.Graphics.TBitmap.Create; cVCL := Vcl.Graphics.TCanvas.Create; cVCL.Handle := GetWindowDC(GetDesktopWindow); try bmpVCL.Width := DesktopWidth; bmpVCL.Height := DesktopHeight; bmpVCL.Canvas.CopyRect(Rect(0, 0, DesktopWidth, DesktopHeight), cVCL, Rect(DesktopLeft, DesktopTop, DesktopLeft + DesktopWidth, DesktopTop + DesktopHeight) ); finally ReleaseDC(0, cVCL.Handle); cVCL.Free; end; msBmp := TMemoryStream.Create; try bmpVCL.SaveToStream(msBmp); msBmp.Position := 0; dest.LoadFromStream(msBmp); finally msBmp.Free; end; </code>