From ae285e790d4b2bbc76591b90c8e737af9970ebbb Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Wed, 4 Dec 2019 13:21:11 +0100 Subject: [PATCH] tests: Fix image writing on big endian The code tried to only write the RGB bytes of FORMAT_RGB24, however, the in-memory layout is different on big-endian which would result in the wrong bytes being written. Fix this by simply also writing the byte we do not care about. --- tests/capture.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/capture.py b/tests/capture.py index 2ad9385..a7b7583 100755 --- a/tests/capture.py +++ b/tests/capture.py @@ -36,10 +36,12 @@ c_buf = c_img.get_data() for x in range(width): for y in range(height): + # The upper byte is don't care, but the location depends on endianness, + # so just set all of them. c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x] c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x] c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x] - # Byte 4 is don't care + c_buf[y * c_rowstride + x * 4 + 3] = buf[y * width + x] c_img.mark_dirty() c_img.write_to_png(sys.argv[1])