Commit 32bab29f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

weight pixels by their alpha value. Fixes the smudge tool (bug #72879).

2003-06-09  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs-generic.h (blend_pixels): weight
	pixels by their alpha value. Fixes the smudge tool (bug #72879).
parent 9d984fb1
2003-06-09 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs-generic.h (blend_pixels): weight
pixels by their alpha value. Fixes the smudge tool (bug #72879).
2003-06-09 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-scripts.c (script_fu_interface):
......@@ -172,13 +172,28 @@ blend_pixels (const guchar *src1,
guint w,
guint bytes)
{
const guchar blend1 = (256 - blend);
const guchar blend2 = (blend + 1);
const guint c = bytes - 1;
guint b;
const guchar blend2 = (255 - blend);
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = (src1[b] * blend2 + src2[b] * blend) / 255;
guint a1 = blend1 * src1[c];
guint a2 = blend2 * src2[c];
guint a = a1 + a2;
if (!a)
{
for (b = 0; b < bytes; b++)
dest[b] = 0;
}
else
{
for (b = 0; b < c; b++)
dest[b] = (src1[b] * a1 + src2[b] * a2) / a;
dest[c] = a >> 8;
}
src1 += bytes;
src2 += bytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment