From 1ed565ff8d1d5139d0ff5fcf9a8a3dda44156bb1 Mon Sep 17 00:00:00 2001 From: kris Date: Tue, 2 Nov 2021 22:14:42 +0000 Subject: [PATCH] Fix a bug with palette depths < 8 --- dither.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dither.pyx b/dither.pyx index 8cf8559..6bcc4b2 100644 --- a/dither.pyx +++ b/dither.pyx @@ -66,7 +66,7 @@ cdef inline unsigned char shift_pixel_window( Returns: n-bit value representing shifted pixel window """ cdef unsigned char window_mask = 0xff >> (8 - window_width) - return ((last_pixels >> shift_right_by) | (next_pixels << (8 - shift_right_by))) & window_mask + return ((last_pixels >> shift_right_by) | (next_pixels << (window_width - shift_right_by))) & window_mask # Look ahead a number of pixels and compute choice for next pixel with lowest total squared error after dithering.