#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Zinc; use Tk::JPEG; use Tk::WinPhoto; my $mw = MainWindow->new; $mw->geometry("700x600"); $mw->resizable(0,0); my $zinc = $mw->Zinc(-width => 700, -height => 500, -backcolor => 'black', -borderwidth => 3, -relief => 'sunken')->pack; # Then we create a gray filled rectangle, in which we will display explain text. $zinc->add('rectangle', 1 , [200, 400, 490, 490], -linewidth => 2, -filled => 1, -fillcolor => 'SkyBlue', ); $zinc->add('rectangle', 1 , [250,275,450,325], #corners (xpos1,ypos1,xpos2,ypos2) -linewidth => 2, -filled => 1, -fillcolor => 'Orange', ); my $closebutton = $mw->Button(-text => 'Exit', -command => sub{Tk::exit(0)}) ->pack; my $zincbutton = $mw->Button(-text=>'Zinc Capture', -command => \&zinc_capture, )->pack; MainLoop; ############################################################### sub zinc_capture{ my $image = $mw->Photo(-format => 'Window', -data => oct($zinc->id) ); my $pathname = './zinc.'.time.'.jpg'; $image->write($pathname, -format => 'JPEG'); } ##############################################################