From 2a574c78ebe833d2e91dde8e1229d4d9d12fb422 Mon Sep 17 00:00:00 2001 From: Paul V Craven Date: Fri, 9 Oct 2026 09:05:48 -0500 Subject: [PATCH] Say when get_image and get_pixel can read the screen Once a frame has been shown, such as in on_key_press, the screen's contents are undefined: on Windows, get_image() returned an all-black image there. Both docstrings now say to call them at the end of on_draw, after drawing (#1342). Co-Authored-By: Claude Opus 5.5 --- arcade/screenshot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arcade/screenshot.py b/arcade/screenshot.py index 28b7a1b0d5..ace2d25660 100644 --- a/arcade/screenshot.py +++ b/arcade/screenshot.py @@ -14,6 +14,10 @@ def get_pixel(x: int, y: int, components: int = 3) -> tuple[int, ...]: """ Given an x, y, will return a color value of that point. + .. note:: Call this at the end of ``on_draw``, after drawing. Once a + frame has been shown, such as in ``on_key_press``, the + screen's contents are undefined and may read as black. + Args: x: x location y: y location @@ -43,9 +47,13 @@ def get_image( """ Get an image from the screen. + .. note:: Call this at the end of ``on_draw``, after drawing. Once a + frame has been shown, such as in ``on_key_press``, the + screen's contents are undefined and may read as black. + Example:: - # Create and image of the entire screen and save it to a file + # At the end of on_draw, save an image of the entire screen image = arcade.get_image() image.save('screenshot.png')