take snapshot in GiD

Moderator: GiD Team

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

take snapshot in GiD

Postby jinsu421 » Tue Aug 14, 2018 3:37 am

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: 1568
Joined: Thu Sep 18, 2014 3:31 pm

Re: take snapshot in GiD

Postby escolano » Sat Aug 18, 2018 6:00 pm

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

Postby jinsu421 » Thu Aug 23, 2018 5:05 am

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/51699559/dealing-with-canvas-copy-trouble-in-tcl

Maybe this problem relevant your mentioned about OpenGL?
User avatar
escolano
Posts: 1568
Joined: Thu Sep 18, 2014 3:31 pm

Re: take snapshot in GiD

Postby escolano » Mon Sep 03, 2018 6:29 pm

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 56 times

Windows x64
img_1.4.7_win_x64.rar
(748.99 KiB) Downloaded 54 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

Postby jinsu421 » Fri Sep 21, 2018 2:50 am

importing New img package helpful.
Thanks to help.

Return to “Customization”

Who is online

Users browsing this forum: No registered users and 1 guest