libfprint/SOURCES/0065-tests-Fix-image-writing-on-big-endian.patch
2021-09-09 20:12:48 +00:00

36 lines
1.2 KiB
Diff

From 1dc9e06987c3787c3e6177fd010e5b0d5eab2ad9 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Wed, 4 Dec 2019 13:21:11 +0100
Subject: [PATCH 065/181] 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])
--
2.24.1