Skip to content

Commit 27b8b33

Browse files
author
dirk
committed
Fixed rotational blur for images with an alpha channel.
1 parent 814561c commit 27b8b33

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

MagickCore/effect.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,7 +2942,8 @@ MagickExport Image *RotationalBlurImage(const Image *image,const double angle,
29422942
}
29432943
gamma=0.0;
29442944
pixel=0.0;
2945-
if ((blur_traits & BlendPixelTrait) == 0)
2945+
if ((GetPixelChannelTraits(image,AlphaChannel) == UndefinedPixelTrait) ||
2946+
(channel == AlphaChannel))
29462947
{
29472948
for (j=0; j < (ssize_t) n; j+=(ssize_t) step)
29482949
{
@@ -2964,6 +2965,9 @@ MagickExport Image *RotationalBlurImage(const Image *image,const double angle,
29642965
}
29652966
for (j=0; j < (ssize_t) n; j+=(ssize_t) step)
29662967
{
2968+
double
2969+
alpha;
2970+
29672971
r=GetCacheViewVirtualPixels(radial_view, (ssize_t) (blur_center.x+
29682972
center.x*cos_theta[j]-center.y*sin_theta[j]+0.5),(ssize_t)
29692973
(blur_center.y+center.x*sin_theta[j]+center.y*cos_theta[j]+0.5),
@@ -2973,8 +2977,9 @@ MagickExport Image *RotationalBlurImage(const Image *image,const double angle,
29732977
status=MagickFalse;
29742978
continue;
29752979
}
2976-
pixel+=GetPixelAlpha(image,r)*r[i];
2977-
gamma+=GetPixelAlpha(image,r);
2980+
alpha=(double) QuantumScale*GetPixelAlpha(image,r);
2981+
pixel+=alpha*r[i];
2982+
gamma+=alpha;
29782983
}
29792984
gamma=PerceptibleReciprocal(gamma);
29802985
SetPixelChannel(blur_image,channel,ClampToQuantum(gamma*pixel),q);

0 commit comments

Comments
 (0)