autopilot-rs / autopy

A simple, cross-platform GUI automation module for Python and Rust.
https://www.autopy.org/
Apache License 2.0
851 stars 88 forks source link

Crash on windows due to autopy.bitmap.Bitmap size #40

Open banderlog opened 4 years ago

banderlog commented 4 years ago

Hi, python crushes on windows if autopy.bitmap.Bitmap exceeds certain size in pixels/bytes.

On Windows 10 Education (version 1803) it always crashes on >111000 pixels (it's screen scale factor is 1.25, it could be important, imho).

On Windows Server 2019 Datacenter (version 1809) it always crashes on >348000 pixels (1044000 bytes, it's screen scale factor is 1.0).

On linux all fine.

autopy-3.0.0 installed from official wheel Python 3.7.4 conda-4.7.12

Minimal example for replication

import autopy

# 600*580 = 348000
# 600*185 = 111000
tmp = autopy.bitmap.capture_screen(((0, 0), (600, 580)))
len(bytes(tmp))
>> 1044000

tmp = autopy.bitmap.capture_screen(((0, 0), (640, 581)))
len(bytes(tmp))

It should return 1045800, but it crashes without any messages.

I need this to convert screenshots in autopy.bitmap.Bitmap to numpy.ndarray or PIL.Image as it described in #30

UPD: today on Windows Server 2019 Datacenter (version 1809) it decided to crash with bigger images -- 1000x500

msanders commented 4 years ago

Thanks for the report. Which version of Python is this on?

msanders commented 4 years ago

Not sure what the cause of this is at a cursory glance but the bytes implementation is here if anyone wants to take a look at it.

banderlog commented 4 years ago

Thanks for the report. Which version of Python is this on?

python-3.7.4 installed via conda-4.7.12