Repository navigation
Add fetch_pixel(s) method to window for unit testing. #2473
Copy link
Copy link
Closed
Description
Activity
I started on this a while ago ..
I have the following questions:
- What does "spoof window" mean here? @DragonMoffon
- Are our windows always assumed to be RGBA buffers?
- Will all render targets be assumed to be RGBA buffers as well?
- @einarf When you said "I started on this", did you mean the files below?
The
arcade.screenshotfunctionsThis file has commits from einarf in June and August of 2024, and two functions:
Line 15 in 8a41838
def get_pixel(x: int, y: int, components: int = 3) -> tuple[int, ...]: Line 38 in 8a41838
def get_image( Offscreenin the top-levelconftest.py- is exposed as a top-level test fixture available in all tests via
offscreen - was created in August of 2024 by einarf before further work by Eruvanos
It has the following methods of interest
Line 400 in 8a41838
def get_image(self) -> PIL.Image.Image: Line 405 in 8a41838
def read_pixel(self, x, y, components=3) -> tuple[int, int, int, int] | tuple[int, int, int]: Line 415 in 8a41838
def read_region(self, rect: Rect) -> list[tuple[int, int, int, int]]: Line 430 in 8a41838
def read_region_bytes(self, rect: Rect, components=3) -> bytes: Line 437 in 8a41838
def read_region_image(self, rect: Rect, components=3) -> PIL.Image.Image: - added a commit that references this issue
on Oct 8, 2026 Closing this, since pixel testing works in unit tests now:
arcade.get_pixel()andarcade.get_image()work with the test window.tests/unit/test_screenshot.pytests both,tests/unit/draw/test_drawing_primitives.pychecks blended colors withget_pixel, and the reference-scene tests intests/unit/renderingcallget_image().- The
offscreenfixture intests/conftest.pyhasread_pixel,read_region,read_region_imageandassert_images_almost_equal.read_pixelandread_regionused to decode the bytes wrongly; Fix rand_vec_spread_deg directions, large GL reads, and pixel test helpers #2945 fixed them and addedtests/unit/test_offscreen_fixture.py.
A
Windowmethod would do the same thing asarcade.get_pixel(x, y), which already reads from the current window, so we're not adding one.
Metadata
Metadata
Assignees
Labels
testsEverything related to testingEverything related to testing
We currently don't have a concrete way to do pixel testing for unit tests.
get_imagedoesn't play nice with the spoof window. It would hopefully be performant, but it doesn't need to be as aggressively optimized as an official screenshot interface.