-
#!/usr/bin/perl
-
-
#author: zhengsenlin
-
#date: 2013-03-06
-
#desc: Wx ok
-
-
use 5.016;
-
use strict;
-
use warnings;
-
use autodie;
-
use Wx;
-
-
package MyApp;
-
use base 'Wx::App';
-
-
sub OnInit {
-
my $this = @_;
-
my $frame = MyFrame->new("Mini-image demo", [-1, -1], [650, 850]);
-
unless($frame) {print "unable to create frame -- exiting."; return undef}
-
$frame->Show(1);
-
}
-
-
package MyFrame;
-
use base 'Wx::Frame';
-
use Wx qw(wxWidth wxHeight);
-
#use Wx::Image;
-
use IO::File;
-
-
sub new {
-
my $class = shift;
-
my $this = $class->SUPER::new(undef, -1, $_[0], $_[1], $_[2]);
-
my $file = IO::File->new("12062817554.jpg", "r");
-
binmode $file;
-
-
my $handler = Wx::JPEGHandler->new();
-
my $image = Wx::Image->new();
-
my $bmp;
-
$handler->LoadFile($image, $file);
-
$bmp=Wx::Bitmap->new( $image );
-
if ($bmp->Ok()) {
-
$this->{ImageViewer} = Wx::StaticBitmap->new($this, -1, $bmp);
-
}
-
-
my $b1 = Wx::LayoutConstraints->new();
-
$b1->left->Absolute(0);
-
$b1->top->Absolute(0);
-
$b1->width->PercentOf($this, wxWidth, 650);
-
$b1->height->PercentOf($this, wxHeight, 850);
-
-
$this->{ImageViewer}->SetConstraints($b1);
-
$this;
-
-
}
-
-
package main;
-
my $app = MyApp->new();
- $app->MainLoop();