in reply to capture what's on the screen
In my exploration of wxPerl, I came up with the following , it has extra "fluff", but you can clean it to suit you
package ScreenShot; use Wx qw[ :everything ]; use Wx::Colour qw[ :everything ]; use Wx::Event qw[ :everything ]; use Wx::App; use base qw[Wx::App]; sub OnInit { my( $self )=@_; if(1){ # my $w = new Wx::Frame(undef,-1,"crap",[-1,-1,],[-1,-1],wxTRAN +SPARENT_WINDOW ); my $w = new Wx::Frame(undef,-1,"crap",[-1,-1,],[-1,-1],wxTRANS +PARENT_WINDOW ); # my $w = new Wx::Frame(undef,-1,"crap",[-1,-1,],[-1,-1],wxSTAY +_ON_TOP); # my $w = new Wx::Frame(undef,-1,"crap",[-1,-1,],[-1,-1],wxNO_B +ORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION ) +; # my $w = new Wx::Frame(undef,-1,"crap",[-1,-1,],[-1,-1],wxSTAY +_ON_TOP|wxDEFAULT_FRAME_STYLE|wxNO_BORDER); EVT_PAINT( $w, sub { my($s,$e)=@_; my $dc = Wx::PaintDC->new($s); # must create, to stop crap $self->PaintThisBitch; return 0; }); $w->Show(1); $w->CaptureMouse(); $w->Clear(); $w->Refresh; } EVT_MOTION( $self, sub {warn"@_"}); return 1; } sub TakeScreenshot { my($self, $file ) = @_; $file ||= 'test.bmp'; my $screen = Wx::ScreenDC->new(); my( $x, $y) = $screen->GetSizeWH(); my $bitmap = Wx::Bitmap->new($x,$y,-1); my $memory = Wx::MemoryDC->new(); $memory->SelectObject( $bitmap ); $memory->Blit(0,0,$x,$y, $screen, 0, 0); $bitmap->SaveFile( $file , wxBITMAP_TYPE_BMP ) ; } sub PaintThisBitch { my $screen = Wx::ScreenDC->new(); $screen->SetBackgroundMode( wxTRANSPARENT ); $screen->SetFont(Wx::Font->new( 40, wxDECORATIVE, wxNORMAL, wxBOLD +, 0 )); for(1..255){ my $c = $_; $screen->SetTextForeground( Wx::Colour->newRGB(0,0,$c) +); $screen->DrawRotatedText("wxPerl",410 ,400 ,$_); $screen->DrawRotatedText("wxPerl and PodMaster",410 ,5 +00 ,0); $screen->DrawRotatedText("are messing up your screen", +410 ,550 ,0); select undef, undef, undef, 0.0001; } for(1..255){ my $c = $_; $screen->SetTextForeground( Wx::Colour->newRGB(0,$c,0) +); $screen->DrawRotatedText("wxPerl",410 ,400 ,$_); $screen->DrawRotatedText("wxPerl and PodMaster",410 ,5 +00 ,0); $screen->DrawRotatedText("are messing up your screen", +410 ,550 ,0); select undef, undef, undef, 0.0001; } for(1..255){ my $c = $_; $screen->SetTextForeground( Wx::Colour->newRGB($c,0,0) +); $screen->DrawRotatedText("wxPerl",410 ,400 ,$_); $screen->DrawRotatedText("wxPerl and PodMaster",410 ,5 +00 ,0); $screen->DrawRotatedText("are messing up your screen", +410 ,550 ,0); select undef, undef, undef, 0.0001; } return 0; } package main; my $i = ScreenShot->new; $i->TakeScreenshot('testor.bmp'); $i->PaintThisBitch; $i->MainLoop; __END__ wxScreenDC context = wxClientDC( self ) memory = wxMemoryDC( ) x,y = self.GetClientSizeTuple() bitmap = wxEmptyBitmap( x,y, -1 ) memory.SelectObject( bitmap ) memory.Blit( 0,0,x,y, context, 0,0) memory.SelectObject( wxNullBitmap) bitmap.SaveFile( "test.bmp", wxBITMAP_TYPE_BMP )
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
|---|