prs = gdk_pixbuf_get_rowstride(pb);
p_pix = gdk_pixbuf_get_pixels(pb);
+ const gint p_step = has_alpha ? 4 : 3;
+
for (i = 0; i < h; i++)
{
- pp = p_pix + (y + i) * prs + (x * (has_alpha ? 4 : 3));
+ pp = p_pix + (y + i) * prs + (x * p_step);
for (j = 0; j < w; j++)
{
- *pp = (r * a + *pp * (256-a)) >> 8;
- pp++;
- *pp = (g * a + *pp * (256-a)) >> 8;
- pp++;
- *pp = (b * a + *pp * (256-a)) >> 8;
- pp++;
- if (has_alpha) pp++;
+ pp[0] = (r * a + pp[0] * (256-a)) >> 8;
+ pp[1] = (g * a + pp[1] * (256-a)) >> 8;
+ pp[2] = (b * a + pp[2] * (256-a)) >> 8;
+ pp += p_step;
}
}
}
prs = gdk_pixbuf_get_rowstride(pb);
p_pix = gdk_pixbuf_get_pixels(pb);
+ const gint p_step = has_alpha ? 4 : 3;
+
for (i = 0; i < h; i++)
{
- pp = p_pix + (y + i) * prs + (x * (has_alpha ? 4 : 3));
+ pp = p_pix + (y + i) * prs + (x * p_step);
for (j = 0; j < w; j++)
{
*pp = r; pp++;
while (xa < xb)
{
- *pp = (r * a + *pp * (256-a)) >> 8;
- pp++;
- *pp = (g * a + *pp * (256-a)) >> 8;
- pp++;
- *pp = (b * a + *pp * (256-a)) >> 8;
- pp++;
- if (has_alpha) pp++;
+ pp[0] = (r * a + pp[0] * (256-a)) >> 8;
+ pp[1] = (g * a + pp[1] * (256-a)) >> 8;
+ pp[2] = (b * a + pp[2] * (256-a)) >> 8;
+ pp += p_step;
xa++;
}
for (i = x1; i < x2; i++)
{
if (vertical) n = a - a * abs(i - s) / border;
- *pp = (r * n + *pp * (256-n)) >> 8;
- pp++;
- *pp = (g * n + *pp * (256-n)) >> 8;
- pp++;
- *pp = (b * n + *pp * (256-n)) >> 8;
- pp++;
- if (has_alpha) pp++;
+ pp[0] = (r * n + pp[0] * (256-n)) >> 8;
+ pp[1] = (g * n + pp[1] * (256-n)) >> 8;
+ pp[2] = (b * n + pp[2] * (256-n)) >> 8;
+ pp += p_step;
}
}
}
r = MIN(border, (gint)hypot(i - sx, j - sy));
n = a - a * r / border;
- *pp = (r * n + *pp * (256-n)) >> 8;
- pp++;
- *pp = (g * n + *pp * (256-n)) >> 8;
- pp++;
- *pp = (b * n + *pp * (256-n)) >> 8;
- pp++;
- if (has_alpha) pp++;
+ pp[0] = (r * n + pp[0] * (256-n)) >> 8;
+ pp[1] = (g * n + pp[1] * (256-n)) >> 8;
+ pp[2] = (b * n + pp[2] * (256-n)) >> 8;
+ pp += p_step;
}
}
}
prs = gdk_pixbuf_get_rowstride(pb);
p_pix = gdk_pixbuf_get_pixels(pb);
+ const gint p_step = has_alpha ? 4 : 3;
+
for (i = 0; i < h; i++)
{
- pp = p_pix + (y + i) * prs + (x * (has_alpha ? 4 : 3));
+ pp = p_pix + (y + i) * prs + (x * p_step);
for (j = 0; j < w; j++)
{
guint8 grey;
grey = (pp[0] + pp[1] + pp[2]) / 3;
- *pp = grey;
- pp++;
- *pp = grey;
- pp++;
- *pp = grey;
- pp++;
- if (has_alpha) pp++;
+ pp[0] = grey;
+ pp[1] = grey;
+ pp[2] = grey;
+ pp += p_step;
}
}
}
prs = gdk_pixbuf_get_rowstride(pb);
p_pix = gdk_pixbuf_get_pixels(pb);
+ const gint p_step = has_alpha ? 4 : 3;
+
for (i = 0; i < h; i++)
{
- pp = p_pix + (y + i) * prs + (x * (has_alpha ? 4 : 3));
+ pp = p_pix + (y + i) * prs + (x * p_step);
for (j = 0; j < w; j++)
{
if (pp[0] == 255 || pp[1] == 255 || pp[2] == 255 || pp[0] == 0 || pp[1] == 0 || pp[2] == 0)
{
- *pp = 255;
- pp++;
- *pp = 0;
- pp++;
- *pp = 0;
- pp++;
- if (has_alpha) pp++;
- }
- else
- {
- pp = pp + 3;
- if (has_alpha) pp++;
+ pp[0] = 255;
+ pp[1] = 0;
+ pp[2] = 0;
}
+ pp += p_step;
}
}
}