Any attempt to use the window option on a Mac causes a crash, e.g.,
% package require img::window
1.4.13
% canvas .c
.c
% pack .c
% image create photo -format window -data .c
child killed: illegal instruction
Crash report attached. This is on an arm64 mac running the downloaded x86_64 under Rosetta but my home compiled arm64 version crashes the same way, and so does the x86_64 version on an x86_64 mac
Someone else reported this same crash on tcl-mac, and I explained the cause in a comment dated 2021-04-11 03:07:45 at https://core.tcl-lang.org/tk/tktview/685ac30727
This crash was resolved in Tk Aqua 8.6.12: https://core.tcl-lang.org/tk/info/ef6a385d89 .
image create photo -format windowreportedly now works on Tk Aqua.Thanks for that Christopher...I have updated my sources and rebuilt, and sure enough it no longer crashes. However, I now find that the image created is the same size as the window specified, but shows the top left corner of the toplevel window containing it. To illustrate, here is a set of commands to draw a coloured canvas away from the top left corner, then attempt to make an image of it -- the image ends up showing the two buttons and only part of the canvas
% info patchlevel
8.6.12
% package require Img
1.4.13
% pack [button .b -text "This goes left"]
% pack [button .pl -text "No, this does"] -side left
% pack [canvas .c]
% .c create rect 75 50 225 150 -width 10 -outline red -fill green1
1
% .c config -bg blue
% image create photo -format window -data .c
image1
% image1 write test.png
Thank you for testing with 8.6.12 and reporting the results. I opened a ticket for that issue and have suggested a fix for it: https://core.tcl-lang.org/tk/info/4ac9d2cfd6
Works with Tcl/Tk 8.6.13 and current Img version.
Tested on Windows, Linux, Mac (Intel and AMD).