Use p_step to avoid has_alpha comparison in loop
[geeqie.git] / src / dnd.cc
index 600745e..63c7ee9 100644 (file)
@@ -64,13 +64,15 @@ static void pixbuf_draw_border(GdkPixbuf *pixbuf, gint w, gint h)
                *p = 0; p++; *p = 0; p++; *p = 0; p++;
                if (alpha) { *p= 255; p++; }
                }
+
+       const gint p_step = alpha ? 4 : 3;
        for (i = 1; i < h - 1; i++)
                {
                p = pix + rs * i;
                *p = 0; p++; *p = 0; p++; *p = 0; p++;
                if (alpha) *p= 255;
 
-               p = pix + rs * i + (w - 1) * ((alpha == TRUE) ? 4 : 3);
+               p = pix + rs * i + (w - 1) * p_step;
                *p = 0; p++; *p = 0; p++; *p = 0; p++;
                if (alpha) *p= 255;
                }
@@ -97,9 +99,11 @@ static void pixbuf_draw_rect_unused(GdkPixbuf *pixbuf, gint x, gint y, gint w, g
        rs = gdk_pixbuf_get_rowstride(pixbuf);
        pix = gdk_pixbuf_get_pixels(pixbuf);
 
+       const gint p_step = alpha ? 4 : 3;
+
        for (j = 0; j < h; j++)
                {
-               p = pix + (rs * (y + j)) + (x * ((alpha) ? 4 : 3));
+               p = pix + (rs * (y + j)) + (x * p_step);
                for (i = 0; i < w; i++)
                        {
                        *p = (*p * (256-val)) >> 8; p++;