# HG changeset patch # User Matti Hamalainen # Date 1526466149 -10800 # Node ID dacf4c2f7a86c5157da9aa598b0eeb92793b0e4c # Parent 4c96181c9c09f6351949dca8e59b23c59ca548c5 Remove slight code duplication. diff -r 4c96181c9c09 -r dacf4c2f7a86 tools/libgfx.c --- a/tools/libgfx.c Wed May 16 13:19:26 2018 +0300 +++ b/tools/libgfx.c Wed May 16 13:22:29 2018 +0300 @@ -1601,13 +1601,16 @@ } +static inline Uint8 dmDecodeBit(const Uint8 *src, const int xc) +{ + return (buf[xc / 8] >> (7 - (xc & 7))) & 1; +} + + void dmDecodeBitPlane(Uint8 *dp, const Uint8 *src, const int width, const int nplane) { for (int xc = 0; xc < width; xc++) - { - const Uint8 data = (src[xc / 8] >> (7 - (xc & 7))) & 1; - dp[xc] |= (data << nplane); - } + dp[xc] |= dmDecodeBit(src, xc) << nplane; } @@ -1675,7 +1678,7 @@ // Decode mask for (int xc = 0; xc < img->width; xc++) { - const Uint8 data = (buf[xc / 8] >> (7 - (xc & 7))) & 1; + const Uint8 data = dmDecodeBit(buf, xc); // Black out any pixels with mask bit 0 if (!data)