How to save a capture the mobile screen on a bitmap?

Asked

Viewed 67 times

1

I would like to capture the entire screen of the phone, but what I’ve achieved so far only captures the control passed in the function parameter. follows the code below:

//USO:
var
  B: TBitmap;
begin
  B:= MakeScaleScreenshot(Self);
  Image1.Bitmap.Assign(B);
  B.DisposeOf;
end;

//FUNCAO:
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
        Result := ScreenService.GetScreenScale;
  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;

Whatever hint is welcome.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.