*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;
}
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++;
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;
}
}
}