take snapshot in GiD

Moderator: GiD Team

Post Reply
jinsu421
Posts: 19
Joined: Tue Jul 10, 2018 5:38 am

take snapshot in GiD

Post by jinsu421 »

Hi, I'm using Windows(OS).

I want to take a snapshot in my new toplevel widgets (having a canvas widgets).

And i find Gid Script(proc takesnapshot in PostWidgets.tcl),

So i want make extension proc about takesnapshot in my scripts.

Can you help me?
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: take snapshot in GiD

Post by escolano »

You can try to create an 'img' object with our procedure defined in 'dev_kit.tcl'
(but maybe it only works depending on your graphic card or the OpenGl mode by hardware or software)

GidUtils::CaptureWindow $w
where w is the tk name of your toplevel or your canvas

set x [GidUtils::CaptureWindow $w]

and for example you can save it to disk with something like this
$x write $filename -format PNG
jinsu421
Posts: 19
Joined: Tue Jul 10, 2018 5:38 am

Re: take snapshot in GiD

Post by jinsu421 »

I'm trying GidUtils::CaptureWindow procedure.

and occured error "Window not mapped while creating image "

This problem is solved using "update" keyword helpful.

But, maked file (.png file) nothing to draw.

reference my stackoverflow question helpful.

https://stackoverflow.com/questions/516 ... ble-in-tcl

Maybe this problem relevant your mentioned about OpenGL?
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: take snapshot in GiD

Post by escolano »

I have tried, for example creating a mesh of triangles, opening the Mesh->Quality window and capturing the image of the mesh quality canvas, with a code like this:
set x [GidUtils::CaptureWindow .gid.meshq.f.nb.fTriangle.c]
$x write {C:\temp\mesh_quality.png} -format PNG

or this
set x [image create photo -format window -data .gid.meshq.f.nb.fTriangle.c]
$x write {C:\temp\mesh_quality.png} -format PNG

and the image was created, but corrupted (only the upper part of the image was properly filled)
It seems that the problem is related with the version of the Tcl Img package 1.4.1 used in GiD in Windows.
Updating it to version 1.4.7 works well. (On Linux it is working wel with the version 1.4.6)

Next GiD 14.0.2 official and 14.1.0d developer will include this version of the Img package.

Note: you can fix your current GiD Windows version simply replacing the current folder <gid>/scripts/img by this attached files
Windows x32
img_1.4.7_win_x32.rar
(736.11 KiB) Downloaded 327 times
Windows x64
img_1.4.7_win_x64.rar
(748.99 KiB) Downloaded 338 times
(use the x32 or x64 version depending on your GiD platform)
jinsu421
Posts: 19
Joined: Tue Jul 10, 2018 5:38 am

Re: take snapshot in GiD

Post by jinsu421 »

importing New img package helpful.
Thanks to help.
Post Reply