Skip to content

Commit

Permalink
Issue pythonarcade#594, get_image returning incorrect crop
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Mar 24, 2020
1 parent 8a1307a commit d73ffc0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arcade/draw_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,22 @@ def get_image(x: int = 0, y: int = 0, width: int = None, height: int = None):

# Get the dimensions
window = get_window()

if window is None:
raise RuntimeError("Handle to the current window is None")

pixel_ratio = window.get_pixel_ratio()
x = int(pixel_ratio * x)
y = int(pixel_ratio * y)

if width is None:
width = window.width - x
if height is None:
height = window.height - y

width = int(pixel_ratio * width)
height = int(pixel_ratio * height)

# Create an image buffer
# noinspection PyTypeChecker
image_buffer = (gl.GLubyte * (4 * width * height))(0)
Expand Down

0 comments on commit d73ffc0

Please sign in to comment.