From 639fc61f603399ff4169551b1b5d01780378576b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:03:44 +0100 Subject: [PATCH] (gfx/rpng) Correct copy_line_bw --- gfx/rpng/rpng.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gfx/rpng/rpng.c b/gfx/rpng/rpng.c index c21af16700..2f9d01f5c9 100644 --- a/gfx/rpng/rpng.c +++ b/gfx/rpng/rpng.c @@ -303,11 +303,10 @@ static inline void copy_line_rgba(uint32_t *data, static inline void copy_line_bw(uint32_t *data, const uint8_t *decoded, unsigned width, unsigned depth) { - unsigned i, bit = 0; + unsigned i, bit; static const unsigned mul_table[] = { 0, 0xff, 0x55, 0, 0x11, 0, 0, 0, 0x01 }; - unsigned mul = mul_table[depth]; - unsigned mask = (1 << depth) - 1; - + unsigned mul, mask; + if (depth == 16) { for (i = 0; i < width; i++) @@ -318,6 +317,10 @@ static inline void copy_line_bw(uint32_t *data, return; } + mul = mul_table[depth]; + mask = (1 << depth) - 1; + bit = 0; + for (i = 0; i < width; i++, bit += depth) { unsigned byte = bit >> 3;