Page 1 of 1

take snapshot in GiD

Posted: Tue Aug 14, 2018 3:37 am
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?

Re: take snapshot in GiD

Posted: Sat Aug 18, 2018 6:00 pm
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

Re: take snapshot in GiD

Posted: Thu Aug 23, 2018 5:05 am
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?

Re: take snapshot in GiD

Posted: Mon Sep 03, 2018 6:29 pm
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 326 times
Windows x64
img_1.4.7_win_x64.rar
(748.99 KiB) Downloaded 337 times
(use the x32 or x64 version depending on your GiD platform)

Re: take snapshot in GiD

Posted: Fri Sep 21, 2018 2:50 am
by jinsu421
importing New img package helpful.
Thanks to help.