Re: Get Tk::Canvas pixels
"John" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <005501c4d84f$ffc6ef60$747882c3@jonsof> |
----- Original Message ----- From: "Ala Qumsieh" <[email protected]> To: "John" <[email protected]>; <[email protected]> Sent: Thursday, December 02, 2004 7:46 AM Subject: Re: Get Tk::Canvas pixels > > I have toyed before with code that checks every > location on a Canvas, and finds what the topmost item > is, and put()s the fill color of that item in the > corresponding location in a Photo object. Something > like this: > > use Tk 804; > use Tk::PNG; > > sub canv2PNG { > my $c = shift; # the canvas > my $outF = 'out.png'; > $mw->Busy; > > my $p = $mw->Photo(-height => $c->height, > -width => $c->width, > -format => 'png', > ); > > for my $x (0 .. $c->width - 1) { > for my $y (0 .. $c->height - 1) { > my @i = $c->find(overlapping => $x, $y, $x, > $y); > defined $i[0] or next; > > my $tag = $i[-1]; > my $col = $c->itemcget($tag, '-fill'); > $p->put([$col], -to => $x, $y); > } > } > > $p->write($outF, -format => 'png'); > $mw->Unbusy; > } > > But it has some severe limitations: > > - Only handles simple items: Lines, Rectangles, > Polygons and Ovals. No Text. > - Does not output the -outline color. > - Does not handle transparency and stipples. > - Is somewhat slow. > > I'm not sure how to address those issues. > > If your application can live with them, then that > might be a good solution. > > --Ala > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > Well PPM> install Tk::PNG Install package 'Tk-PNG?' (y/N): y Installing package 'Tk-PNG'... Error installing package 'Tk-PNG': Read a PPD for 'Tk-PNG', but it is not intend ed for this build of Perl (MSWin32-x86-multi-thread) I have no luck :(:(:( Is there any other module (something Tk::BMP, Tk::JPEG), which can do the job? -++**==--++**==--++**==--++**==--++**==--++**==--++**== This message was posted through the Stanford campus mailing list server. If you wish to unsubscribe from this mailing list, send the message body of "unsubscribe ptk" to [email protected]