fixed the non-alpha case (bug #116470).

2003-07-01  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/ripple.c (average_four_pixels): fixed the
	non-alpha case (bug #116470).
This commit is contained in:
Sven Neumann
2003-07-01 16:53:33 +00:00
committed by Sven Neumann
parent 7e6b71c8fd
commit a6264ada31
2 changed files with 38 additions and 24 deletions

View File

@ -1,3 +1,8 @@
2003-07-01 Sven Neumann <sven@gimp.org>
* plug-ins/common/ripple.c (average_four_pixels): fixed the
non-alpha case (bug #116470).
2003-07-01 Jakub Steiner <jimmac@ximian.com> 2003-07-01 Jakub Steiner <jimmac@ximian.com>
* app/gui/image-menu.c * app/gui/image-menu.c

View File

@ -299,6 +299,7 @@ ripple (GimpDrawable *drawable)
gimp_pixel_rgn_init (&dest_rgn, drawable, gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE); x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (1, &dest_rgn); for (pr = gimp_pixel_rgns_register (1, &dest_rgn);
pr != NULL; pr != NULL;
pr = gimp_pixel_rgns_process (pr)) pr = gimp_pixel_rgns_process (pr))
@ -378,7 +379,7 @@ ripple (GimpDrawable *drawable)
} /* for */ } /* for */
progress += dest_rgn.w * dest_rgn.h; progress += dest_rgn.w * dest_rgn.h;
gimp_progress_update ((double) progress / (double) max_progress); gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
} }
else /* HORIZONTAL */ else /* HORIZONTAL */
{ {
@ -650,17 +651,20 @@ average_two_pixels (guchar *dest,
gint b; gint b;
x = fmod (x, 1.0); x = fmod (x, 1.0);
if (has_alpha) if (has_alpha)
{ {
double xa0 = pixels[0][bpp-1] * (1.0 - x); gdouble xa0 = pixels[0][bpp-1] * (1.0 - x);
double xa1 = pixels[1][bpp-1] * x; gdouble xa1 = pixels[1][bpp-1] * x;
double alpha; gdouble alpha;
alpha = xa0 + xa1; alpha = xa0 + xa1;
dest[bpp-1] = alpha;
if (dest[bpp-1]) if (alpha)
for (b = 0; b < bpp-1; b++) for (b = 0; b < bpp-1; b++)
dest[b] = (xa0 * pixels[0][b] + xa1 * pixels[1][b]) / alpha; dest[b] = (xa0 * pixels[0][b] + xa1 * pixels[1][b]) / alpha;
dest[bpp-1] = alpha;
} }
else else
{ {
@ -679,26 +683,31 @@ average_four_pixels (guchar *dest,
gint b; gint b;
x = fmod (x, 1.0); x = fmod (x, 1.0);
if (has_alpha) if (has_alpha)
{ {
double xa0 = pixels[0][bpp-1] * (1.0 - x)/2; gdouble xa0 = pixels[0][bpp-1] * (1.0 - x) / 2;
double xa1 = pixels[1][bpp-1] * x/2; gdouble xa1 = pixels[1][bpp-1] * x / 2;
double xa2 = pixels[2][bpp-1] * (1.0 - x)/2; gdouble xa2 = pixels[2][bpp-1] * (1.0 - x) / 2;
double xa3 = pixels[3][bpp-1] * x/2; gdouble xa3 = pixels[3][bpp-1] * x / 2;
double alpha; gdouble alpha;
alpha = xa0 + xa1 + xa2 + xa3; alpha = xa0 + xa1 + xa2 + xa3;
dest[bpp-1] = alpha;
if (dest[bpp-1]) if (alpha)
for (b = 0; b < bpp-1; b++) for (b = 0; b < bpp-1; b++)
dest[b] = (xa0 * pixels[0][b] + xa1 * pixels[1][b] dest[b] = (xa0 * pixels[0][b] +
+ xa2 * pixels[2][b] + xa3 * pixels[3][b])/alpha; xa1 * pixels[1][b] +
xa2 * pixels[2][b] +
xa3 * pixels[3][b]) / alpha;
dest[bpp-1] = alpha;
} }
else else
{ {
for (b = 0; b < bpp; b++) for (b = 0; b < bpp; b++)
dest[b] = (1.0 - x) * (pixels[0][b] + pixels[2][b]) dest[b] = ((1.0 - x) * (pixels[0][b] + pixels[2][b]) / 2 +
+ x * (pixels[1][b] + pixels[3][b]); x * (pixels[1][b] + pixels[3][b]) / 2);
} }
} }