Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
[Answered, no solution] GetFormImage on MacOS generates black bitmap
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Lazarus Main not building...
by
dbannon
[
Today
at 05:03:33 am]
Putting a new file on a w...
by
jamie
[
Today
at 02:26:32 am]
Setting the CURSOR for th...
by
jamie
[
Today
at 02:16:55 am]
Windows 2026_7 update and...
by
jamie
[
Today
at 01:45:40 am]
Stopped compiling witout ...
by
jamie
[
Today
at 12:28:38 am]
TPeriodicTable
by
wp
[
Today
at 12:19:25 am]
authentiacte through goog...
by
Packs
[July 17, 2026, 08:52:36 pm]
FPC Unleashed (async/awai...
by
Fibonacci
[July 17, 2026, 08:26:50 pm]
I have made some progress...
by
onionmixer
[July 17, 2026, 08:08:34 pm]
Slow app start on M5 MacB...
by
Martin_fr
[July 17, 2026, 07:54:04 pm]
How to connect to MariaDb...
by
jcmontherock
[July 17, 2026, 06:23:38 pm]
This week in OPM!
by
Tomxe
[July 17, 2026, 05:47:11 pm]
Accessing VRAM memory wit...
by
LemonParty
[July 17, 2026, 04:45:30 pm]
KOL4 Beta available.
by
Thaddy
[July 17, 2026, 04:45:13 pm]
docking IDE
by
Martin_fr
[July 17, 2026, 02:13:28 pm]
Engineering Software from...
by
jamie
[July 17, 2026, 12:51:57 pm]
GTK3 is now the default w...
by
bonmario
[July 17, 2026, 12:50:59 pm]
FastCGI vs. CGI
by
korba812
[July 17, 2026, 12:48:06 pm]
[SOLVED] BitBtn Oddity
by
Petrus Vorster
[July 17, 2026, 09:05:55 am]
Difference between @ and ...
by
paule32
[July 17, 2026, 08:18:43 am]
Lazarus Bugfix Release 4....
by
papillon33
[July 17, 2026, 08:15:45 am]
Many recent books on Laza...
by
Khrys
[July 17, 2026, 06:35:48 am]
Isn’t this funny?
by
n7800
[July 16, 2026, 11:57:09 pm]
Error when opening a proj...
by
Tomu
[July 16, 2026, 09:11:54 pm]
Is this safe, changing fr...
by
mas steindorff
[July 16, 2026, 08:46:31 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Answered, no solution] GetFormImage on MacOS generates black bitmap (Read 2265 times)
wittbo
Full Member
Posts: 152
[Answered, no solution] GetFormImage on MacOS generates black bitmap
«
on:
June 03, 2019, 02:46:46 pm »
Given this simple procedure:
procedure TmyForm.Button1Click(Sender: TObject);
var bm: TBitmap;
begin
bm := myForm.GetFormImage;
bm.Canvas.Changed;
bm.SaveToFile('/users/myuser/downloads/test.bmp');
bm.Free
end;
The file gets generated with the correct dimensions width and height, but the contents of the bitmap in the file is entirely black.
Any idea?
Does GetFormImage only work on Windows?
«
Last Edit: June 05, 2019, 10:41:19 am by wittbo
»
Logged
-wittbo-
MBAir M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
lucamar
Hero Member
Posts: 4217
Re: GetFormImage on MacOS generates black bitmap
«
Reply #1 on:
June 03, 2019, 04:59:55 pm »
Quote from: wittbo on June 03, 2019, 02:46:46 pm
Does GetFormImage only work on Windows?
No, it works also on Linux. See attached image, made using:
Code: Pascal
[Select]
[+]
[-]
procedure
TMainForm
.
btDoTestClick
(
Sender
:
TObject
)
;
var
Bitmap
:
TBitmap
;
begin
Bitmap
:
=
GetFormImage
;
if
Assigned
(
Bitmap
)
then
try
{Bitmap.Canvas.Changed; - not needed: there's no OnChange handler}
Bitmap
.
SaveToFile
(
'test.bmp'
)
;
Image
.
Picture
.
LoadFromFile
(
'test.bmp'
)
;
finally
Bitmap
.
Free
;
end
;
end
;
Unrelated, but note that it is
very bad practice
to reference the auto-created form instance inside the methods. If you realy need to reference the current object use
Self
, as in:
Self.GetFormImage
Logged
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!)
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.
bylaardt
Sr. Member
Posts: 310
Re: GetFormImage on MacOS generates black bitmap
«
Reply #2 on:
June 04, 2019, 01:52:17 am »
this reminds me of an old topic:
https://forum.lazarus.freepascal.org/index.php/topic,27896.msg173144.html#msg173144
Logged
wittbo
Full Member
Posts: 152
Re: GetFormImage on MacOS generates black bitmap
«
Reply #3 on:
June 04, 2019, 11:13:43 am »
Sorry, but none of the solutions (GetFormimage, ...copyrect, ...) does work on MacOS. The Bitmap remains black.
I believe, it is a special MacOS problem(or cocoa): i will copy a link to this thread into the macos forum.
Logged
-wittbo-
MBAir M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
bylaardt
Sr. Member
Posts: 310
Re: GetFormImage on MacOS generates black bitmap
«
Reply #4 on:
June 04, 2019, 05:19:47 pm »
even paintto?
Logged
wittbo
Full Member
Posts: 152
Re: GetFormImage on MacOS generates black bitmap
«
Reply #5 on:
June 05, 2019, 10:39:47 am »
Skalogryz wrote in the correspondent macos thread:
that's easy. The function has not been implemented for cocoa yet
https://forum.lazarus.freepascal.org/index.php/topic,45606.0.html
Therefore actually no solution for Mac users.
Logged
-wittbo-
MBAir M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
bylaardt
Sr. Member
Posts: 310
Re: [Answered, no solution] GetFormImage on MacOS generates black bitmap
«
Reply #6 on:
June 05, 2019, 03:46:14 pm »
have you try?
Code: Pascal
[Select]
[+]
[-]
MyCapture
:
=
TBitMap
.
Create
(
application
)
;
MyCapture
.
SetSize
(
ClientWidth
,
ClientHeight
)
;
MyCapture
.
canvas
.
FillRect
(
0
,
0
,
ClientWidth
,
ClientHeight
)
;
self
.
PaintTo
(
MyCapture
.
canvas
,
0
,
0
)
;
MyCapture
.
SaveToFile
(
'/home/bylaardt/MyFormImage.bmp'
)
;
MyCapture
.
free
;
Logged
wittbo
Full Member
Posts: 152
Re: [Answered, no solution] GetFormImage on MacOS generates black bitmap
«
Reply #7 on:
June 06, 2019, 11:56:39 am »
Sorry, just tested.
But now the Image isn't black, now it's completely white.
Logged
-wittbo-
MBAir M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
[Answered, no solution] GetFormImage on MacOS generates black bitmap
TinyPortal
© 2005-2018