Commit c1ec2765 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

shift only by 4 bits instead of 8. Should still keep us from overflowing

2007-10-30  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-render.c (box_filter): shift only
	by 4 bits instead of 8. Should still keep us from overflowing 32
	bit integers but reduces the rounding error and seems to really
	fix bug #491503.


svn path=/trunk/; revision=23996
parent 8f6682a5
2007-10-30 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c (box_filter): shift only
by 4 bits instead of 8. Should still keep us from overflowing 32
bit integers but reduces the rounding error and seems to really
fix bug #491503.
2007-10-30 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangleselecttool.c
......
......@@ -256,8 +256,6 @@ gimp_display_shell_render (GimpDisplayShell *shell,
info.alpha = render_image_init_alpha (opacity * 255.999);
}
/* Setup RenderInfo for rendering a GimpProjection level. */
{
TileManager *src_tiles;
......@@ -272,17 +270,9 @@ gimp_display_shell_render (GimpDisplayShell *shell,
gimp_display_shell_render_info_scale (&info, shell, src_tiles, level);
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998.
*
* I retired them before they reach the age of 9 years unused...
* -- simon, 23rd Sep 2007.
*/
/* Currently, only RGBA and GRAYA projection types are used. */
type = gimp_projection_get_image_type (projection);
if (G_UNLIKELY (type != GIMP_RGBA_IMAGE && type != GIMP_GRAYA_IMAGE))
g_warning ("using untested projection type %d", type);
switch (type)
{
case GIMP_RGBA_IMAGE:
......@@ -292,7 +282,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
render_image_gray_a (&info);
break;
default:
g_printerr ("gimp_display_shell_render: unsupported projection type\n");
g_warning ("%s: unsupported projection type (%d)", G_STRFUNC, type);
g_assert_not_reached ();
}
......@@ -686,7 +676,7 @@ box_filter (const guint left_weight,
const gint bpp)
{
const guint sum = ((left_weight + center_weight + right_weight) *
(top_weight + middle_weight + bottom_weight)) >> 8;
(top_weight + middle_weight + bottom_weight)) >> 4;
switch (bpp)
{
......@@ -695,15 +685,15 @@ box_filter (const guint left_weight,
{
guint factors[9] =
{
(src[1][ALPHA] * top_weight) >> 8,
(src[4][ALPHA] * middle_weight) >> 8,
(src[7][ALPHA] * bottom_weight) >> 8,
(src[2][ALPHA] * top_weight) >> 8,
(src[5][ALPHA] * middle_weight) >> 8,
(src[8][ALPHA] * bottom_weight) >> 8,
(src[0][ALPHA] * top_weight) >> 8,
(src[3][ALPHA] * middle_weight) >> 8,
(src[6][ALPHA] * bottom_weight) >> 8
(src[1][ALPHA] * top_weight) >> 4,
(src[4][ALPHA] * middle_weight) >> 4,
(src[7][ALPHA] * bottom_weight) >> 4,
(src[2][ALPHA] * top_weight) >> 4,
(src[5][ALPHA] * middle_weight) >> 4,
(src[8][ALPHA] * bottom_weight) >> 4,
(src[0][ALPHA] * top_weight) >> 4,
(src[3][ALPHA] * middle_weight) >> 4,
(src[6][ALPHA] * bottom_weight) >> 4
};
guint a = (center_weight * (factors[0] + factors[1] + factors[2]) +
......@@ -730,7 +720,7 @@ box_filter (const guint left_weight,
) / a) & 0xff;
}
dest[ALPHA] = (a + (sum >> 1) + (sum >> 2)) / sum;
dest[ALPHA] = (a + (sum >> 1)) / sum;
}
else
{
......@@ -749,15 +739,15 @@ box_filter (const guint left_weight,
{
guint factors[9] =
{
(src[1][ALPHA] * top_weight) >> 8,
(src[4][ALPHA] * middle_weight) >> 8,
(src[7][ALPHA] * bottom_weight) >> 8,
(src[2][ALPHA] * top_weight) >> 8,
(src[5][ALPHA] * middle_weight) >> 8,
(src[8][ALPHA] * bottom_weight) >> 8,
(src[0][ALPHA] * top_weight) >> 8,
(src[3][ALPHA] * middle_weight) >> 8,
(src[6][ALPHA] * bottom_weight) >> 8
(src[1][ALPHA] * top_weight) >> 4,
(src[4][ALPHA] * middle_weight) >> 4,
(src[7][ALPHA] * bottom_weight) >> 4,
(src[2][ALPHA] * top_weight) >> 4,
(src[5][ALPHA] * middle_weight) >> 4,
(src[8][ALPHA] * bottom_weight) >> 4,
(src[0][ALPHA] * top_weight) >> 4,
(src[3][ALPHA] * middle_weight) >> 4,
(src[6][ALPHA] * bottom_weight) >> 4
};
guint a = (center_weight * (factors[0] + factors[1] + factors[2]) +
......@@ -784,7 +774,7 @@ box_filter (const guint left_weight,
) / a) & 0xff;
}
dest[ALPHA] = (a + (sum >> 1) + (sum >> 2)) / sum;
dest[ALPHA] = (a + (sum >> 1)) / sum;
}
else
{
......
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