mirror of
https://github.com/morgan9e/libfprint-fpc1020
synced 2026-04-14 00:14:16 +09:00
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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user