Pathologically Eclectic Rubbish Lister PerlMonks

### Problem with postscript capturing of Tk::AbstractCanvas

by KuntalBhusan (Acolyte)
 on Nov 29, 2012 at 15:11 UTC Need Help??
KuntalBhusan has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,I used to capture a postscript image (which consisted of a graph with nodes and edges) in Tk::Canvas using a code as below :
```my (\$miny, \$maxy) = (1000000000000000000, -1000000000000000000);
my (\$minx, \$maxx) = (1000000000000000000, -1000000000000000000);

## Stored all node coordinate information in @graph_node

for(my \$i=0;\$i<@graph_node;\$i++)
{

my (\$x,\$y) = \$graph_node[\$i]->get_coords;
\$maxy = \$y if \$y > \$maxy;
\$miny = \$y if \$y < \$miny;

\$maxx = \$x if \$x > \$maxx;
\$minx = \$x if \$x < \$minx;

}

\$maxx = \$maxx + 90;
\$maxy = \$maxy + 90;
\$minx = \$minx - 90;
\$miny = \$miny - 90;

@capture=('-x'=>\$minx,'-y'=>\$miny,-height=>\$maxy-\$miny,-width
+=>\$maxx-\$minx);
\$scrolled_can->postscript(-colormode=>'color',
-file=> "\$screenshot_path",
-rotate=>0,
-width=>2400,
-height=>3400,
@capture);

I used the above strategy instead of
```my (\$xt0,\$yt0,\$xt1,\$yt1) = \$_canvas{0}->bbox('all');
because sometimes the bbox capture did not capture the canvas properly .

Now when I started working with Tk::Abstract Canvas, this capture does not work properly (both the methods). It mostly captures some partial areas of the AbstractCanvas and not the full.

Is it possible to solve this problem in AbstractCanvas. It would also be great if you can help me getting some other way to capture the canvas in a .jpeg or .tiff or .svg or some format that is more often used (in windows). Presently I am working with Linux but I need to make my code work for windows as well with the capture image of the whole canvas.

Any help would be highly appreciated...Thanks

Replies are listed 'Best First'.
Re: Problem with postscript capturing of Tk::AbstractCanvas
by Anonymous Monk on Nov 29, 2012 at 15:31 UTC
Ha! ha! this works for me  qw/ -x -1200 -y -1200 -width 2400 -height 2400 /,

Create A New User
Node Status?
node history
Node Type: perlquestion [id://1006267]
Approved by Old_Gray_Bear
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-04-20 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (78 votes). Check out past polls.

Notices?