#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::WinPhoto; use Tk::JPEG; my $image = shift || 'zen16.jpg'; #test image colors my $mw = tkinit; $mw->geometry("200x400+100+100"); my $canv; my $mainbutton = $mw->Button(-text=>'MainWindow Capture', -command => \&mw_capture, )->pack; my $canvbutton = $mw->Button(-text=>'Canvas Capture', -command => sub{ &canv_capture}, )->pack; $canv = $mw->Scrolled('Canvas', -width=>2400, -height=>3400, -scrollregion=>[0,0,2400,3400], -scrollbars=>'osoe') ->pack(-fill=>'both', -expand=>1); my $img = $mw->Photo(-file => $image ); $canv->createImage( 0, 0, -image => $img, -anchor => 'nw' ); # Create line inside the canvas upper area $canv->create ('line',1, 1, 3000, 3400, -fill=>'red'); $canv->createRectangle(10,20,30,40, -fill=>'blue' ); # Create line inside the lower area $canv->createRectangle(400,400,800,800, -fill=>'blue' ); # Create line inside the lower right area $canv->createRectangle(2000,3000,3000,3400, -fill=>'blue' ); MainLoop; ######################################################### sub mw_capture{ my $image = $mw->Photo(-format => 'Window', -data => oct($mw->id) # # -data => oct('0xa00022') # -data => oct($id) ); my $pathname = $0.'-mainwindow.'.time.'.jpg'; $image->write($pathname, -format => 'JPEG'); } ########################################################## sub canv_capture{ #$canv->configure(-height=>2400, -width =>3400); #$mw->update; my $image = $mw->Photo(-format => 'Window', -data => oct($canv->id) ); my $pathname = $0.'-canvas.'.time.'.jpg'; $image->write($pathname, -format => 'JPEG'); } ##############################################################
In reply to Re: Tk Canvas WinPhoto Colors are changed in jpg
by zentara
in thread Tk Canvas WinPhoto Colors are changed in jpg
by rickrutgers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |