3

I need the code that allowed my to take screenshots programmatically in Delphi. Here is the sulotion:

How to programmatically take a screenshot on Android?

How can i do this in delphi android app? This is my code but only capture Tcontrols not android screen.

function MakeScaleScreenshot(Sender:TControl): TBitmap;
var
  fScreenScale: Single;

  function GetScreenScale: Single;
  var
    ScreenService: IFMXScreenService;
  begin
    Result := 1;
    if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then
    begin
      Result := ScreenService.GetScreenScale;
    end;
  end;

begin
  fScreenScale := GetScreenScale;
  Result := TBitmap.Create(Round(Sender.Width*fScreenScale), Round(Sender.Height*fScreenScale));
  Result.Clear(0);
  if Result.Canvas.BeginScene then
  try
    Sender.PaintTo(Result.Canvas, RectF(0,0,Result.Width,Result.Height));
  finally
    Result.Canvas.EndScene;
  end;
end;
Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • 3
    I tried the Delphi equivalents of https://stackoverflow.com/a/5651242/3164070 and https://stackoverflow.com/a/51875893/3164070, however neither worked (status bar and screen were blank). Using this might work: https://github.com/mtsahakis/MediaProjectionDemo however it would be a much more substantial effort to implement – Dave Nottage Nov 29 '20 at 20:31

0 Answers0