fixed calculation of the alpha value.

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

	* app/display/gimpdisplayshell-render.c (box_filter): fixed
	calculation of the alpha value.


svn path=/trunk/; revision=23864
This commit is contained in:
Sven Neumann
2007-10-18 08:07:26 +00:00
committed by Sven Neumann
parent 84b7f76315
commit 4bfde23c61
2 changed files with 49 additions and 34 deletions

View File

@ -1,3 +1,8 @@
2007-10-18 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c (box_filter): fixed
calculation of the alpha value.
2007-10-17 Sven Neumann <sven@gimp.org> 2007-10-17 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c (box_filter): sprinkled * app/display/gimpdisplayshell-render.c (box_filter): sprinkled

View File

@ -47,10 +47,10 @@
#include "gimpdisplayshell-filter.h" #include "gimpdisplayshell-filter.h"
#include "gimpdisplayshell-render.h" #include "gimpdisplayshell-render.h"
#define GIMP_DISPLAY_ZOOM_FAST 1 << 0 /* use the fastest possible code #define GIMP_DISPLAY_ZOOM_FAST (1 << 0) /* use the fastest possible code
path trading quality for speed path trading quality for speed
*/ */
#define GIMP_DISPLAY_ZOOM_PIXEL_AA 1 << 1 /* provide AA edges when zooming in #define GIMP_DISPLAY_ZOOM_PIXEL_AA (1 << 1) /* provide AA edges when zooming in
on the actual pixels (in current on the actual pixels (in current
code only enables it between code only enables it between
100% and 200% zoom) 100% and 200% zoom)
@ -90,7 +90,6 @@ struct _RenderInfo
gint footprint_x; gint footprint_x;
gint footprint_y; gint footprint_y;
gint footarea;
gint footshift_x; gint footshift_x;
gint footshift_y; gint footshift_y;
@ -656,8 +655,6 @@ gimp_display_shell_render_info_scale (RenderInfo *info,
info->footprint_y <<= 1; info->footprint_y <<= 1;
info->footshift_y ++; info->footshift_y ++;
} }
info->footarea = info->footprint_x * info->footprint_y;
} }
static const guint * static const guint *
@ -688,15 +685,15 @@ box_filter (const guint left_weight,
const guint top_weight, const guint top_weight,
const guint middle_weight, const guint middle_weight,
const guint bottom_weight, const guint bottom_weight,
const guint sum,
const guchar **src, /* the 9 surrounding source pixels */ const guchar **src, /* the 9 surrounding source pixels */
guchar *dest, guchar *dest,
const gint bpp) const gint bpp)
{ {
const guint sum = ((left_weight + center_weight + right_weight) *
(top_weight + middle_weight + bottom_weight)) >> 8;
switch (bpp) switch (bpp)
{ {
gint i;
case 4: case 4:
#define ALPHA 3 #define ALPHA 3
{ {
@ -717,11 +714,11 @@ box_filter (const guint left_weight,
right_weight * (factors[3] + factors[4] + factors[5]) + right_weight * (factors[3] + factors[4] + factors[5]) +
left_weight * (factors[6] + factors[7] + factors[8])); left_weight * (factors[6] + factors[7] + factors[8]));
dest[ALPHA] = a / sum;
for (i = 0; i <= ALPHA; i++)
{
if (a) if (a)
{
gint i;
for (i = 0; i < ALPHA; i++)
{ {
dest[i] = ((center_weight * (factors[0] * src[1][i] + dest[i] = ((center_weight * (factors[0] * src[1][i] +
factors[1] * src[4][i] + factors[1] * src[4][i] +
@ -736,6 +733,12 @@ box_filter (const guint left_weight,
factors[8] * src[6][i]) factors[8] * src[6][i])
) / a) & 0xff; ) / a) & 0xff;
} }
dest[ALPHA] = a / sum;
}
else
{
dest[ALPHA] = 0;
} }
} }
#undef ALPHA #undef ALPHA
@ -743,8 +746,9 @@ box_filter (const guint left_weight,
case 2: case 2:
#define ALPHA 1 #define ALPHA 1
/* NOTE: this is a copy and paste of the code above, the ALPHA changes /* NOTE: this is a copy and paste of the code above, ALPHA changes
* the behavior in all needed ways. */ * the behavior in all needed ways.
*/
{ {
guint factors[9] = guint factors[9] =
{ {
@ -763,11 +767,11 @@ box_filter (const guint left_weight,
right_weight * (factors[3] + factors[4] + factors[5]) + right_weight * (factors[3] + factors[4] + factors[5]) +
left_weight * (factors[6] + factors[7] + factors[8])); left_weight * (factors[6] + factors[7] + factors[8]));
dest[ALPHA] = a / sum;
for (i = 0; i <= ALPHA; i++)
{
if (a) if (a)
{
gint i;
for (i = 0; i < ALPHA; i++)
{ {
dest[i] = ((center_weight * (factors[0] * src[1][i] + dest[i] = ((center_weight * (factors[0] * src[1][i] +
factors[1] * src[4][i] + factors[1] * src[4][i] +
@ -782,6 +786,12 @@ box_filter (const guint left_weight,
factors[8] * src[6][i]) factors[8] * src[6][i])
) / a) & 0xff; ) / a) & 0xff;
} }
dest[ALPHA] = a / sum;
}
else
{
dest[ALPHA] = 0;
} }
} }
#undef ALPHA #undef ALPHA
@ -1034,7 +1044,7 @@ render_image_tile_fault (RenderInfo *info)
} }
box_filter (left_weight, center_weight, right_weight, box_filter (left_weight, center_weight, right_weight,
top_weight, middle_weight, bottom_weight, info->footarea, top_weight, middle_weight, bottom_weight,
src, dest, bpp); src, dest, bpp);
dest += bpp; dest += bpp;
@ -1478,7 +1488,7 @@ render_image_tile_fault_one_row (RenderInfo *info)
} }
box_filter (left_weight, center_weight, right_weight, box_filter (left_weight, center_weight, right_weight,
top_weight, middle_weight, bottom_weight, info->footarea, top_weight, middle_weight, bottom_weight,
src, dest, bpp); src, dest, bpp);
dest += bpp; dest += bpp;