Imager-Screenshot
view release on metacpan or search on metacpan
Screenshot.pm view on Meta::CPAN
sub have_x11 {
defined &_x11;
}
sub have_darwin {
defined &_darwin;
}
sub x11_open {
my $display = _x11_open(@_);
unless ($display) {
Imager->_set_error(Imager->_error_as_msg);
return;
}
return $display;
}
sub x11_close {
_x11_close(shift);
}
1;
__END__
=head1 NAME
Imager::Screenshot - screenshot to an Imager image
=head1 SYNOPSIS
use Imager::Screenshot 'screenshot';
# whole screen
my $img = screenshot();
# Win32 window
my $img2 = screenshot(hwnd => $hwnd);
# X11 window
my $img3 = screenshot(display => $display, id => $window_id);
# X11 tools
my $display = Imager::Screenshot::x11_open();
Imager::Screenshot::x11_close($display);
# test for win32 support
if (Imager::Screenshot->have_win32) { ... }
# test for x11 support
if (Imager::Screenshot->have_x11) { ... }
# test for Darwin (Mac OS X) support
if (Imager::Screenshot->have_darwin) { ... }
=head1 DESCRIPTION
Imager::Screenshot captures either a desktop or a specified window and
returns the result as an Imager image.
Currently the image is always returned as a 24-bit image.
=over
=item screenshot hwnd => I<window handle>
=item screenshot hwnd => I<window handle>, decor => <capture decorations>
=item screenshot hwnd => "active"
Retrieve a screenshot under Win32, if I<window handle> is zero,
capture the desktop.
By default, window decorations are not captured, if the C<decor>
parameter is set to true then window decorations are included.
As of 0.010 hwnd can also be C<"active"> to capture the active (or
"foreground") window.
=item screenshot hwnd => 0
Retrieve a screeshot of the default desktop under Win32.
=item screenshot hwnd => 0, monitor => -1
Retrieve a screenshot of all attached monitors under Win32.
Note: this returns an image with an alpha channel, since there can be
regions in the bounding rectangle of all monitors that no particular
monitor covers.
=item screenshot hwnd => 0, monitor => I<index>
Retrieve a screenshot from a particular monitor under Win32. A
I<monitor> of zero is always treated as the primary monitor.
If the given monitor is not active screenshot() will fail.
=item screenshot id => I<window id>
=item screenshot id => I<window id>, display => I<display object>
Retrieve a screenshot under X11, if I<id> is zero, capture the root
window. I<display object> is a integer version of an X11 C< Display *
>, if this isn't supplied C<screenshot()> will attempt connect to the
the display specified by $ENV{DISPLAY}.
By default this works by always capturing from the root window,
adjusting for the position of the supplied window if one is supplied.
To capture directly from the window, which returns a completely black
image on some platforms, supply a C<< direct => 1 >> parameter.
Note: taking a screenshot of a remote display is slow.
=item screenshot darwin => 0
Retrieve a screenshot under Mac OS X. The only supported value for
the C<darwin> parameter is C<0>.
For a screen capture to be taken, the current user using
Imager:Screenshot must be the currently logged in user on the display.
If you're using fast user switching, the current user must be the
active user.
Note: this means you can ssh into a Mac OS X box and screenshot from
the ssh session, if you're the current user on the display.
=item screenshot widget => I<widget>
=item screenshot widget => I<widget>, display => I<display>
=item screenshot widget => I<widget>, decor => I<capture decorations>
Retrieve a screenshot of a Tk widget, under Win32 or X11, depending on
how Tk has been built.
If Tk was built for X11 then the display parameter applies.
If Tk was built for Win32 then the decor parameter applies.
( run in 1.521 second using v1.01-cache-2.11-cpan-c221a9de4ec )