changeset 1619:dacf4c2f7a86

Remove slight code duplication.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 16 May 2018 13:22:29 +0300
parents 4c96181c9c09
children 469f363292b8
files tools/libgfx.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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)