Jump to content
Turan Can

full screen view capture

Recommended Posts

Hello everyone,

 

Full screenshot.

How do I capture the entire screen?

 

In this example, I can take a screenshot of the open form.

Sample;

 

function MakeScaleScreenshot(Sender: TObject): 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(TfmText1(Sender).Width * fScreenScale), Round(TfmText1(Sender).Height * fScreenScale));
  Result.Clear(0);
  if Result.Canvas.BeginScene then
    try
      TfmText1(Sender).PaintTo(Result.Canvas);
      // Sender.PaintTo( Result.Canvas); //, RectF(0, 0, Result.Width, Result.Height));
    finally
      Result.Canvas.EndScene;
    end;
end;

 

procedure TfmText1.btnScreenClick(Sender: TObject);
var
  B: TBitmap;
begin

  B := MakeScaleScreenshot(Self);

  // MakeScreenshot(Image1);
  Image1.Bitmap.Assign(B);
  B.DisposeOf;
end;

 

 

 

Screenshot_20210128-090432_One UI Home.jpg

Edited by Turan Can

Share this post


Link to post

Doh! 
The risks of reading the Unread Content list and not paying attention which subforum the post is in.

My bad.

Share this post


Link to post

In the Java example, it did not capture the entire screen, but took a screenshot of the form it was attached to.
so it is no different from the sample code I made.

 

I think I need to take a screenshot with a handle from a plugin or api. but I could not find any examples android.

 

Delphi, Java, C# xamarin

I could not find an example of a full screenshot for android in these 3 languages.

 

1- Java sample

2- java sample

Edited by Turan Can

Share this post


Link to post

Hi limelect,

 

As I share in the picture, can it get the top bar and bottom bar showing clock and battery?

Share this post


Link to post

It works by taking the whole!  Android screen and puts it in a video including audio!!!

I compiled it in Android Studio.

Share this post


Link to post

Limelect, 

 

There is no code language issue for me. I am reviewing what you sent.

Thanks a lot for the information.

There are several api used in the code you sent, I'll review them.

Edited by Turan Can
  • Like 1

Share this post


Link to post
Guest

in FMX you can use "Layout" component (covering the entire application area - main form, for example) in your forms or in main-form or any other control that can use "MakeScreenShot" procedure!

  • FMX.Controls.TControl.MakeScreenshot
  • Takes and returns a screenshot of the control = to a bitmap

 

for easy use, you can create a "template" for all forms - visual inherit

program Project1;

uses
  System.StartUpCopy,
  FMX.Forms,
  uTemplateForAllForms in 'uTemplateForAllForms.pas' {frmTemplateForAllForms} ,
  uFormMain in 'uFormMain.pas' {frmFormMain};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TfrmFormMain, frmFormMain);
  Application.Run;

end.
type
  TfrmTemplateForAllForms = class(TForm)
    Layout1: TLayout;  // align = client - and it will be the "container" for all other components 
    btnMakeScreenShot: TButton;
    procedure btnMakeScreenShotClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmTemplateForAllForms: TfrmTemplateForAllForms;

implementation

{$R *.fmx}

procedure TfrmTemplateForAllForms.btnMakeScreenShotClick(Sender: TObject);
var
  lMyBitmap: TBitmap;
begin
  // return a bitmap for a public/private "var" like this
  lMyBitmap := Layout1.MakeScreenshot;
end;
...
   uTemplateForAllForms, FMX.Controls.Presentation, FMX.Layouts;

type
  TfrmFormMain = class(TfrmTemplateForAllForms)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmFormMain: TfrmFormMain; // this my main-form on Project-Options

hug

Edited by Guest

Share this post


Link to post

The problem is solved. I convert from the Java example.
Thanks. It only receives the form you send. Please check the picture above.

 

  • Like 1

Share this post


Link to post
On 2/5/2021 at 6:34 AM, Turan Can said:

The problem is solved. I convert from the Java example.
Thanks. It only receives the form you send. Please check the picture above.

 

How you solved this problem Can you put Your Code Hier ?

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×