| 1 | package Imager::Search::Screenshot; | ||
| 2 | |||
| 3 | =pod | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Imager::Search::Screenshot - An image captured from the screen | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | B<Imager::Search::Screenshot> is a L<Imager::Search::Image> subclass | ||
| 12 | that allows you to capture images from the screen. | ||
| 13 | |||
| 14 | This provides a convenient mechanism to source the target images for | ||
| 15 | applications that need to (visually) monitor an existing graphical system. | ||
| 16 | |||
| 17 | =head1 METHODS | ||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | 3 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 3 | ▶ | use Carp (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 3 | ▶ | use Params::Util (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 0 | ▶ | use Imager::Screenshot (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 26 | use Imager::Search::Image (); | ||
| 27 | |||
| 28 | use vars qw{$VERSION @ISA}; | ||
| 29 | BEGIN { | ||
| 30 | $VERSION = '1.01'; | ||
| 31 | @ISA = 'Imager::Search::Image'; | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | ##################################################################### | ||
| 39 | # Constructor and Accessors | ||
| 40 | |||
| 41 | =head2 new | ||
| 42 | |||
| 43 | my $image = Imager::Search::Screenshot->new( | ||
| 44 | [ id => 0 ], | ||
| 45 | driver => 'BMP24', | ||
| 46 | ); | ||
| 47 | |||
| 48 | The C<new> constructor initates a screen capture and returns the image. | ||
| 49 | |||
| 50 | In addition to params inherited from L<Imager::Search::Image> it | ||
| 51 | additionally can take as the first parameter a reference to an ARRAY. | ||
| 52 | |||
| 53 | It provided, the contents of the ARRAY are passed through to the underlying | ||
| 54 | L<Imager::Screenshot> C<screenshot> method, which is used to do the actual | ||
| 55 | image capture. | ||
| 56 | |||
| 57 | Returns a new L<Imager::Search::Screenshot> object, or dies | ||
| 58 | on error. | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | sub new { | ||
| 63 | my $class = shift; | ||
| 64 | my @params = (); | ||
| 65 | @params = @{shift()} if Params::Util::_ARRAY0($_[0]); | ||
| 66 | my $image = Imager::Screenshot::screenshot( @params ); | ||
| 67 | unless ( Params::Util::_INSTANCE($image, 'Imager') ) { | ||
| 68 | Carp::croak('Failed to capture screenshot'); | ||
| 69 | } | ||
| 70 | |||
| 71 | # Hand off to the parent class | ||
| 72 | return $class->SUPER::new( image => $image, @_ ); | ||
| 73 | } | ||
| 74 | |||
| 75 | 1; | ||
| 76 | |||
| 77 | =pod | ||
| 78 | |||
| 79 | =head1 SUPPORT | ||
| 80 | |||
| 81 | See the SUPPORT section of the main L<Imager::Search> module. | ||
| 82 | |||
| 83 | =head1 AUTHOR | ||
| 84 | |||
| 85 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||
| 86 | |||
| 87 | =head1 COPYRIGHT | ||
| 88 | |||
| 89 | Copyright 2007 - 2011 Adam Kennedy. | ||
| 90 | |||
| 91 | This program is free software; you can redistribute | ||
| 92 | it and/or modify it under the same terms as Perl itself. | ||
| 93 | |||
| 94 | The full text of the license can be found in the | ||
| 95 | LICENSE file included with this module. | ||
| 96 | |||
| 97 | =cut | ||