Commit 3974e5ee authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

Attempt to finally fix Smudge tool problems (bug #115057):

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

        Attempt to finally fix Smudge tool problems (bug #115057):

	* app/paint-funcs/paint-funcs-generic.h (blend_pixels): added an
	implementation for the non-alpha case.

	* app/paint/gimpsmudge.c (gimp_smudge_start): added back code that
	used to prefill the buffer if the inital area was clipped.
parent 7cb3c316
2003-06-13 Sven Neumann <sven@gimp.org>
Attempt to finally fix Smudge tool problems (bug #115057):
* app/paint-funcs/paint-funcs-generic.h (blend_pixels): added an
implementation for the non-alpha case.
* app/paint/gimpsmudge.c (gimp_smudge_start): added back code that
used to prefill the buffer if the inital area was clipped.
2003-06-13 Sven Neumann <sven@gimp.org>
 
* app/core/gimptemplate.c (gimp_template_create_image): fixed a
......@@ -166,41 +166,58 @@ color_pixels (guchar *dest,
inline void
blend_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guchar blend,
guint w,
guint bytes)
const guchar *src2,
guchar *dest,
guchar blend,
guint w,
guint bytes)
{
const guint blend1 = 256 - blend;
const guint blend2 = blend + 1;
const guint c = bytes - 1;
guint b;
while (w--)
if (HAS_ALPHA (bytes))
{
guint a1 = blend1 * src1[c];
guint a2 = blend2 * src2[c];
guint a = a1 + a2;
const guint blend1 = 256 - blend;
const guint blend2 = blend + 1;
const guint c = bytes - 1;
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;
}
while (w--)
{
guint a1 = blend1 * src1[c];
guint a2 = blend2 * src2[c];
guint a = a1 + a2;
src1 += bytes;
src2 += bytes;
dest += bytes;
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;
dest += bytes;
}
}
}
else
{
const guchar blend1 = 255 - blend;
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = (src1[b] * blend1 + src2[b] * blend) / 255;
src1 += bytes;
src2 += bytes;
dest += bytes;
}
}
}
inline void
shade_pixels (const guchar *src,
......
......@@ -207,13 +207,35 @@ gimp_smudge_start (GimpPaintCore *paint_core,
if (!area)
return FALSE;
/* adjust the x and y coordinates to the upper left corner of the brush */
gimp_smudge_nonclipped_painthit_coords (paint_core, &x, &y, &w, &h);
/* Allocate the accumulation buffer */
smudge->accumPR.bytes = gimp_drawable_bytes (drawable);
smudge->accum_data = g_malloc0 (w * h * smudge->accumPR.bytes);
smudge->accum_data = g_malloc (w * h * smudge->accumPR.bytes);
/* If clipped, fill the smudge buffer with the color at the brush position. */
if (x != area->x || y != area-> || w != area->widht || h != area->height)
{
guchar *fill;
fill = gimp_drawable_get_color_at (drawable,
CLAMP ((gint) paint_core->cur_coords.x,
0, gimp_item_width (GIMP_ITEM (drawable)) - 1),
CLAMP ((gint) paint_core->cur_coords.y,
0, gimp_item_height (GIMP_ITEM (drawable)) - 1));
g_return_val_if_fail (fill != NULL, FALSE);
srcPR.w = w;
srcPR.h = h;
srcPR.bytes = smudge->accumPR.bytes;
srcPR.rowstride = srcPR.bytes * w;
srcPR.data = smudge->accum_data;
color_region (&srcPR, fill);
g_free (fill);
}
smudge->accumPR.x = area->x - x;
smudge->accumPR.y = area->y - y;
......
Supports Markdown
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