From a8e5d471fe35164cbf2529a2c0042ca465f6f159 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Mon, 30 Dec 2024 14:59:23 +0100 Subject: [PATCH] fix(python): fix toif generation from grayscale [no changelog] --- python/src/trezorlib/toif.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/src/trezorlib/toif.py b/python/src/trezorlib/toif.py index 4c81bcce20..7c119145bd 100644 --- a/python/src/trezorlib/toif.py +++ b/python/src/trezorlib/toif.py @@ -94,7 +94,7 @@ def _from_pil_grayscale( data = bytearray() for y in range(0, height): - for x in range(0, width & (width - 1), 2): + for x in range(0, width & ~1, 2): i = y * width + x left, right = pixels[i], pixels[i + 1] @@ -121,7 +121,7 @@ def _from_pil_grayscale_alpha( ) -> bytes: data = bytearray() for y in range(0, height): - for x in range(0, width & (width - 1), 2): + for x in range(0, width & ~1, 2): i = y * width + x left_w_alpha, right_w_alpha = pixels[i], pixels[i + 1] left = int((left_w_alpha[0] * left_w_alpha[1]) / 255)