register const double
*k;
+ register ssize_t
+ u;
+
ssize_t
- u,
v;
(void) LogMagickEvent(TransformEvent,GetMagickModule(),
register ssize_t
x;
- size_t
+ ssize_t
channels,
convolve_channels;
for (i=0; i < (ssize_t) channels; i++)
{
- const Quantum
- *restrict center;
-
MagickRealType
+ alpha,
+ gamma,
pixel;
PixelChannel
ssize_t
v;
- channel=GetPixelChannelMapChannel(image,i);
traits=GetPixelChannelMapTraits(image,i);
+ if (traits == UndefinedPixelTrait)
+ continue;
+ channel=GetPixelChannelMapChannel(image,i);
convolve_traits=GetPixelChannelMapTraits(convolve_image,channel);
- if ((traits == UndefinedPixelTrait) ||
- (convolve_traits == UndefinedPixelTrait))
+ if (convolve_traits == UndefinedPixelTrait)
continue;
- pixel=image->bias;
+ if ((convolve_traits & CopyPixelTrait) != 0)
+ {
+ const Quantum
+ *restrict center;
+
+ center=p+((image->columns+width)*width/2)*channels+i;
+ SetPixelChannel(convolve_image,channel,*center,q);
+ continue;
+ }
k=normal_kernel;
kernel_pixels=p;
- center=p+((image->columns+width)*width/2)*channels+i;
- if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) == 0) ||
+ pixel=image->bias;
+ if ((GetPixelAlphaTraits(image) == UndefinedTrait) ||
(image->matte == MagickFalse))
{
/*
- No alpha blending (optimized).
+ No alpha blending.
*/
for (v=0; v < (ssize_t) width; v++)
{
}
kernel_pixels+=(image->columns+width)*channels;
}
- if ((convolve_traits & UpdatePixelTrait) != 0)
- SetPixelChannel(convolve_image,channel,ClampToQuantum(pixel),q);
+ SetPixelChannel(convolve_image,channel,ClampToQuantum(pixel),q);
+ continue;
+ }
+ /*
+ Alpha blending.
+ */
+ gamma=0.0;
+ for (v=0; v < (ssize_t) width; v++)
+ {
+ for (u=0; u < (ssize_t) width; u++)
+ {
+ alpha=(MagickRealType) (QuantumScale*GetPixelAlpha(image,
+ kernel_pixels+u*channels));
+ if ((traits & BlendPixelTrait) == 0)
+ pixel+=(*k)*kernel_pixels[u*channels+i];
else
- if ((convolve_traits & CopyPixelTrait) != 0)
- SetPixelChannel(convolve_image,channel,*center,q);
+ pixel+=(*k)*alpha*kernel_pixels[u*channels+i];
+ gamma+=(*k)*alpha;
+ k++;
}
+ kernel_pixels+=(image->columns+width)*channels;
+ }
+ if ((convolve_traits & BlendPixelTrait) == 0)
+ SetPixelChannel(convolve_image,channel,ClampToQuantum(pixel),q);
else
{
- MagickRealType
- alpha,
- gamma;
-
- /*
- Alpha blending (unoptimized).
- */
- gamma=0.0;
- for (v=0; v < (ssize_t) width; v++)
- {
- for (u=0; u < (ssize_t) width; u++)
- {
- alpha=(MagickRealType) (QuantumScale*GetPixelAlpha(image,
- kernel_pixels+u*channels));
- if ((traits & BlendPixelTrait) == 0)
- pixel+=(*k)*kernel_pixels[u*channels+i];
- else
- pixel+=(*k)*alpha*kernel_pixels[u*channels+i];
- gamma+=(*k)*alpha;
- k++;
- }
- kernel_pixels+=(image->columns+width)*channels;
- }
gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
- if ((convolve_traits & UpdatePixelTrait) != 0)
- {
- if ((convolve_traits & BlendPixelTrait) == 0)
- SetPixelChannel(convolve_image,channel,ClampToQuantum(pixel),
- q);
- else
- SetPixelChannel(convolve_image,channel,ClampToQuantum(gamma*
- pixel),q);
- }
- else
- if ((convolve_traits & CopyPixelTrait) != 0)
- SetPixelChannel(convolve_image,channel,*center,q);
+ SetPixelChannel(convolve_image,channel,ClampToQuantum(gamma*pixel),
+ q);
}
}
p+=channels;