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
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
Converting excel to csv -...
by
wp
[
Today
at 04:45:46 pm]
Fern Leaf Fractal (Recurs...
by
Boleeman
[
Today
at 04:38:53 pm]
Feature request: hard typ...
by
Warfley
[
Today
at 04:27:27 pm]
Trouble compiling fpc for...
by
ccrause
[
Today
at 04:10:41 pm]
Persistent MacOS Arm M ch...
by
Thaddy
[
Today
at 03:53:25 pm]
MDI ChildForm
by
Dzandaa
[
Today
at 01:40:35 pm]
Pappas Chain Ring: Not Ro...
by
Boleeman
[
Today
at 01:06:20 pm]
control '' has no parent
by
dbannon
[
Today
at 01:00:56 pm]
Creating .deb packages fo...
by
CM630
[
Today
at 12:36:36 pm]
controls.lpr(731,15) Erro...
by
tetrastes
[
Today
at 12:04:54 pm]
Lazarus IDE crashes ( Due...
by
Martin_fr
[
Today
at 11:38:05 am]
Hint windows misplaced an...
by
DimTim
[
Today
at 11:08:12 am]
Compiler don't know the S...
by
Khrys
[
Today
at 08:11:30 am]
activex.pp definition pro...
by
Thaddy
[
Today
at 08:04:36 am]
My DIY dynamic array occu...
by
Thaddy
[
Today
at 06:06:50 am]
Forte Report CE Questions
by
PascalProg
[
Today
at 01:32:42 am]
Canvas.PolyBezier
by
wp
[
Today
at 12:16:24 am]
InstallAware 2025 Sources...
by
msintle
[July 07, 2025, 11:49:05 pm]
[SOLVED] Lazarus IDE 4 UI...
by
Psacla_63
[July 07, 2025, 11:03:06 pm]
Conant Fractal (Close to ...
by
Boleeman
[July 07, 2025, 10:38:58 pm]
problem with certain char...
by
tetrastes
[July 07, 2025, 09:22:02 pm]
Fast Canvas Library V1.05...
by
Lulu
[July 07, 2025, 07:58:57 pm]
Library for drawing a pat...
by
gidesa
[July 07, 2025, 07:43:59 pm]
Sutcliffe Fractal: Anothe...
by
Joanna
[July 07, 2025, 02:16:29 pm]
Billowing Flower: A Tenta...
by
Joanna
[July 07, 2025, 02:13:22 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Answered, no solution] GetFormImage on MacOS generates black bitmap (Read 2041 times)
wittbo
Full Member
Posts: 151
[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: 4219
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: 151
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: 151
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: 151
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