line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 is a L 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
|
|
|
3
|
|
61243
|
use 5.006; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
129
|
|
22
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
92
|
|
23
|
3
|
|
|
3
|
|
17
|
use Carp (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
44
|
|
24
|
3
|
|
|
3
|
|
2516
|
use Params::Util (); |
|
3
|
|
|
|
|
15077
|
|
|
3
|
|
|
|
|
117
|
|
25
|
3
|
|
|
3
|
|
4154
|
use Imager::Screenshot (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
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 constructor initates a screen capture and returns the image. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
In addition to params inherited from L 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 C method, which is used to do the actual |
55
|
|
|
|
|
|
|
image capture. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns a new L 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 module. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
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 |