Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 screenshot of desktop does not take monitor scaling into account #531

Open
rotan-hanrahan opened this issue Aug 17, 2024 · 3 comments

Comments

@rotan-hanrahan
Copy link

In Windows 10 with a 3840x2160 monitor with "Scale and layout" set to 125% via the Windows Display Settings, a screenshot should have the same dimensions as the physical pixel of the monitor, but instead returns an image that is 3072x1728. Note that if you multiply these incorrect dimensions by 1.25 you get 3840x2160.

use Imager::Screenshot 'screenshot';
my $im = screenshot();
my $window_width  = $im->tags(name => 'ss_window_width');
my $window_height = $im->tags(name => 'ss_window_height');
my $window_type   = $im->tags(name => 'ss_type');
print "$window_width x $window_height using $window_type\n";

The output of the above is:

3072 x 1728 using Win32

The expected output, indicating the correct screenshot dimensions, would be:

3840 x 2160 using Win32

The captured screenshot image can be written to file via:

$im->write(file => "screenshot.png", type => 'png');

The written image has been cropped to the incorrect dimensions.

@tonycoz
Copy link
Owner

tonycoz commented Aug 20, 2024

Thanks, I won't be able to look at this until I get my laptop back from being repaired, which should be within a couple of weeks.

@tonycoz
Copy link
Owner

tonycoz commented Sep 15, 2024

I've reproduced this, and multiple screens isn't working either.

I'll probably have to largely rewrite the Win32 capture.

I could just turn on hidpi awareness for the process, but that could cause windows (if any) that belong to the process to redraw

@rotan-hanrahan
Copy link
Author

Is it possible to make hi-dpi awareness an option and that way let the users of your implementation decide for themselves if they want to risk redraws? In my particular use case I have a non-GUI scripted process (i.e. has no windows of its own) that needs to take full screenshots of a given monitor from time to time. Redrawing is presumably not an issue in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants