Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-12

TForm.GetFormImage is broken?

9 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fabio Luis Girardi

Hi!

Currently I'm trying to use TForm.GetFormImage method to make a minimap (something similar to Sublime Text editor) of a big form (the parent of this big form is a TScrollbox on this application).

But, using Qt or GTK2, Lazarus 1.6.3 or trunk, I got the same black bitmap.

So, I created a empty application (just one form with some buttons) and the result is the same.

The code that should make a screenshot of my form is:

procedure TForm1.Button3Click(Sender: TObject);
var
  bmp: TBitmap;
begin
  bmp:=Form1.GetFormImage;
  try
    bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp');
  finally
    FreeAndNil(bmp);
  end;
end;

Am I using the method GetFormImage right?

If yes, what's the alternative method to make a screenshot of a form?

Should I fill a bug report for this issue?

The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161226/1397a430/attachment.html>

Reply by email

Balázs Székely
to Fabio Luis Girardi

Hi,

Am I using the method GetFormImage right?

Yes,

Should I fill a bug report for this issue?

No.

Please try this:
var
  bmp: TBitmap;
begin
  bmp:=Form1.GetFormImage;
  try
    *bmp.Canvas.Changed;*
    bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp');
  finally
    FreeAndNil(bmp);
  end;
end;

On Mon, Dec 26, 2016 at 9:38 PM, Fabio Luis Girardi via Lazarus <

Show quoted text 49 lines
wrote: Hi! Currently I'm trying to use TForm.GetFormImage method to make a minimap (something similar to Sublime Text editor) of a big form (the parent of this big form is a TScrollbox on this application). But, using Qt or GTK2, Lazarus 1.6.3 or trunk, I got the same black bitmap. So, I created a empty application (just one form with some buttons) and the result is the same. The code that should make a screenshot of my form is: procedure TForm1.Button3Click(Sender: TObject); var bmp: TBitmap; begin bmp:=Form1.GetFormImage; try bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp'); finally FreeAndNil(bmp); end; end; Am I using the method GetFormImage right? If yes, what's the alternative method to make a screenshot of a form? Should I fill a bug report for this issue? -- The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161226/9083fb94/attachment.html>

Reply by email

Fabio Luis Girardi
to Balázs Székely

It worked. Thanks!

Why is necessary to call the TCanvas.Changed after TForm1.GetFormImage?

2016-12-26 17:58 GMT-02:00 Balázs Székely :

Show quoted text 75 lines
Hi, Am I using the method GetFormImage right? > Yes, Should I fill a bug report for this issue? > No. Please try this: var bmp: TBitmap; begin bmp:=Form1.GetFormImage; try *bmp.Canvas.Changed;* bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp'); finally FreeAndNil(bmp); end; end; On Mon, Dec 26, 2016 at 9:38 PM, Fabio Luis Girardi via Lazarus < > wrote: > Hi! > > Currently I'm trying to use TForm.GetFormImage method to make a minimap > (something similar to Sublime Text editor) of a big form (the parent of > this big form is a TScrollbox on this application). > > But, using Qt or GTK2, Lazarus 1.6.3 or trunk, I got the same black > bitmap. > > So, I created a empty application (just one form with some buttons) and > the result is the same. > > The code that should make a screenshot of my form is: > > procedure TForm1.Button3Click(Sender: TObject); > var > bmp: TBitmap; > begin > bmp:=Form1.GetFormImage; > try > bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp'); > finally > FreeAndNil(bmp); > end; > end; > > Am I using the method GetFormImage right? > > If yes, what's the alternative method to make a screenshot of a form? > > Should I fill a bug report for this issue? > > -- > The best regards, > > Fabio Luis Girardi > PascalSCADA Project > http://sourceforge.net/projects/pascalscada > http://www.pascalscada.com > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus-ide.org/listinfo/lazarus > >
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161226/ecb6649b/attachment.html>

Reply by email

Werner Pamler
to Balázs Székely: Am I using the method GetFormImage right? Should I fill a bug report for this issue? No.…
Show quoted text 12 lines
Please try this: var bmp: TBitmap; begin bmp:=Form1.GetFormImage; try *bmp.Canvas.Changed;* bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp'); finally FreeAndNil(bmp); end; end;

But Delphi does not require the bmp.Canvas.Changed. Shouldn't it be added to the GetFormImage internally to make this simple code Delphi-compatible?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161227/390d23ec/attachment-0001.html>

Reply by email

Balázs Székely
to Werner Pamler
But Delphi does not require the bmp.Canvas.Changed. Shouldn't it be added to the GetFormImage internally to make this simple code Delphi-compatible?

That's a good idea. The current behavior is confusing.

On Tue, Dec 27, 2016 at 1:40 AM, Werner Pamler via Lazarus <

Show quoted text 28 lines
wrote: Please try this: var bmp: TBitmap; begin bmp:=Form1.GetFormImage; try *bmp.Canvas.Changed;* bmp.SaveToFile(ExtractFilePath(Application.ExeName)+'form.bmp'); finally FreeAndNil(bmp); end; end; But Delphi does not require the bmp.Canvas.Changed. Shouldn't it be added to the GetFormImage internally to make this simple code Delphi-compatible? -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161227/4d6af2fe/attachment.html>

Reply by email

Michael W. Vogel
to Balázs Székely
Balázs Székely wrote 6 lines
But Delphi does not require the bmp.Canvas.Changed. Shouldn't it be added to the GetFormImage internally to make this simple code Delphi-compatible? That's a good idea. The current behavior is confusing.

See comments: http://bugs.freepascal.org/view.php?id=25448

Kind regards

Michl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161227/3994ed2d/attachment.html>

Reply by email

Giuliano Colla
to Juha Manninen

Il 27/12/2016 17:49, Juha Manninen via Lazarus ha scritto:

Somebody with good knowledge of the graphics code should fix it. I remember I tried over 2 years ago but failed.

Just adding a line to GetFormImage does the trick:

Show quoted text 17 lines
function TForm1.GetFormImage: TBitmap; var ARect: TRect; begin Result := TBitmap.Create; try Result.Width := ClientWidth; Result.Height := ClientHeight; LCLIntf.GetWindowRect(Handle, ARect); with GetClientOrigin do PaintTo(Result.Canvas, ARect.Left - X, ARect.Top - Y); except Result.Free; raise; end; Result.Canvas.Changed; <--- This line added end;

Giuliano

Reply by email

Michael W. Vogel
to Juha Manninen: Somebody with good knowledge of the graphics code should fix it. I remember I tried over…

The method TWinControl.PaintTo doesn't refresh the RawImage.Data, like it is done in TRasterImage.Draw. It isn't only a issue for the method GetFormImage. I fixed it in revision 53790. As far as I can see, there are no additional calls done, as the needed one (e.g. TWin32WidgetSet.RawImage_FromBitmap is only called one time before saving to stream).

Hope, it works now as expected. If not, please report.

Michl

Reply by email