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.
This commit is contained in:
Benjamin Berg 2019-12-04 13:21:11 +01:00
parent 1e2f19ea3d
commit ae285e790d

View file

@ -36,10 +36,12 @@ c_buf = c_img.get_data()
for x in range(width): for x in range(width):
for y in range(height): 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 + 0] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 1] = 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] 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.mark_dirty()
c_img.write_to_png(sys.argv[1]) c_img.write_to_png(sys.argv[1])