% MagickCore Image Composite Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include "MagickCore/cache.h"
#include "MagickCore/cache-private.h"
#include "MagickCore/cache-view.h"
+#include "MagickCore/channel.h"
#include "MagickCore/client.h"
#include "MagickCore/color.h"
#include "MagickCore/color-private.h"
h,
m,
r,
- x,
- z;
+ x;
/*
Convert HCL to RGB colorspace.
r=c;
b=x;
}
- m=luma-(0.298839f*r+0.586811f*g+0.114350f*b);
- /*
- Choose saturation strategy to clip it into the RGB cube; hue and luma are
- preserved and chroma may be changed.
- */
- z=1.0;
- if (m < 0.0)
- {
- z=luma/(luma-m);
- m=0.0;
- }
- else
- if (m+c > 1.0)
- {
- z=(1.0-luma)/(m+c-luma);
- m=1.0-z*c;
- }
- *red=QuantumRange*(z*r+m);
- *green=QuantumRange*(z*g+m);
- *blue=QuantumRange*(z*b+m);
+ m=luma-(0.298839*r+0.586811*g+0.114350*b);
+ *red=QuantumRange*(r+m);
+ *green=QuantumRange*(g+m);
+ *blue=QuantumRange*(b+m);
}
static void CompositeHCL(const MagickRealType red,const MagickRealType green,
h=0.0;
else
if (red == max)
- h=fmod(6.0+(g-b)/c,6.0);
+ h=fmod((g-b)/c+6.0,6.0);
else
if (green == max)
h=((b-r)/c)+2.0;
h=((r-g)/c)+4.0;
*hue=(h/6.0);
*chroma=QuantumScale*c;
- *luma=QuantumScale*(0.298839f*r+0.586811f*g+0.114350f*b);
+ *luma=QuantumScale*(0.298839*r+0.586811*g+0.114350*b);
}
static MagickBooleanType CompositeOverImage(Image *image,
Sc: source color.
Dc: destination color.
*/
- if (GetPixelMask(image,q) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
q+=GetPixelChannels(image);
continue;
source,exception);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- PixelTrait
- composite_traits,
- traits;
-
- channel=GetPixelChannelChannel(image,i);
- traits=GetPixelChannelTraits(image,channel);
- composite_traits=GetPixelChannelTraits(composite_image,channel);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ PixelTrait composite_traits=GetPixelChannelTraits(composite_image,
+ channel);
if ((traits == UndefinedPixelTrait) ||
(composite_traits == UndefinedPixelTrait))
continue;
Sa: normalized source alpha.
Da: normalized destination alpha.
*/
- if (GetPixelMask(composite_image,p) != 0)
+ if (GetPixelReadMask(composite_image,p) == 0)
{
p+=GetPixelChannels(composite_image);
channels=GetPixelChannels(composite_image);
alpha=Sa*(-Da)+Sa+Da;
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- PixelTrait
- composite_traits,
- traits;
-
- channel=GetPixelChannelChannel(image,i);
- traits=GetPixelChannelTraits(image,channel);
- composite_traits=GetPixelChannelTraits(composite_image,channel);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ PixelTrait composite_traits=GetPixelChannelTraits(composite_image,
+ channel);
if ((traits == UndefinedPixelTrait) ||
(composite_traits == UndefinedPixelTrait))
continue;
if (composite_image == (const Image *) NULL)
return(MagickFalse);
if (IsGrayColorspace(image->colorspace) != MagickFalse)
- (void) SetImageColorspace(image,RGBColorspace,exception);
+ (void) SetImageColorspace(image,sRGBColorspace,exception);
(void) SetImageColorspace(composite_image,image->colorspace,exception);
if ((image->alpha_trait == BlendPixelTrait) &&
(composite_image->alpha_trait != BlendPixelTrait))
- SetImageAlphaChannel(composite_image,SetAlphaChannel,exception);
+ (void) SetImageAlphaChannel(composite_image,SetAlphaChannel,exception);
if ((compose == OverCompositeOp) || (compose == SrcOverCompositeOp))
{
status=CompositeOverImage(image,composite_image,clip_to_self,x_offset,
register ssize_t
i;
- if (GetPixelMask(composite_image,p) != 0)
+ if (GetPixelReadMask(composite_image,p) == 0)
{
p+=GetPixelChannels(composite_image);
q+=GetPixelChannels(image);
}
for (i=0; i < (ssize_t) GetPixelChannels(composite_image); i++)
{
- PixelChannel
- channel;
-
- PixelTrait
- composite_traits,
- traits;
-
- channel=GetPixelChannelChannel(composite_image,i);
- composite_traits=GetPixelChannelTraits(composite_image,channel);
- traits=GetPixelChannelTraits(image,channel);
+ PixelChannel channel=GetPixelChannelChannel(composite_image,i);
+ PixelTrait composite_traits=GetPixelChannelTraits(composite_image,
+ channel);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
if ((traits == UndefinedPixelTrait) ||
(composite_traits == UndefinedPixelTrait))
continue;
*/
(void) GetOneVirtualPixel(composite_image,x-x_offset,y-y_offset,
source,exception);
- if (GetPixelMask(image,q) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
q+=GetPixelChannels(image);
continue;
MagickRealType
pixel;
- PixelChannel
- channel;
-
- PixelTrait
- composite_traits,
- traits;
-
- channel=GetPixelChannelChannel(image,i);
- traits=GetPixelChannelTraits(image,channel);
- composite_traits=GetPixelChannelTraits(composite_image,channel);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ PixelTrait composite_traits=GetPixelChannelTraits(composite_image,
+ channel);
if ((traits == UndefinedPixelTrait) ||
(composite_traits == UndefinedPixelTrait))
continue;
break;
}
}
- if (GetPixelMask(image,p) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
p+=GetPixelChannels(composite_image);
q+=GetPixelChannels(image);
pixel,
sans;
- PixelChannel
- channel;
-
- PixelTrait
- composite_traits,
- traits;
-
- channel=GetPixelChannelChannel(image,i);
- traits=GetPixelChannelTraits(image,channel);
- composite_traits=GetPixelChannelTraits(composite_image,channel);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ PixelTrait composite_traits=GetPixelChannelTraits(composite_image,
+ channel);
if (traits == UndefinedPixelTrait)
continue;
if ((compose != IntensityCompositeOp) &&
case CopyAlphaCompositeOp:
{
pixel=QuantumRange*Sa;
- if (composite_image->alpha_trait != BlendPixelTrait)
+ if (composite_image->alpha_trait == BlendPixelTrait)
pixel=GetPixelIntensity(composite_image,p);
break;
}
}
case ColorDodgeCompositeOp:
{
- if ((fabs(Sca-Sa) < MagickEpsilon) && (fabs(Dca) < MagickEpsilon))
- {
- pixel=QuantumRange*gamma*(Sca*(1.0-Da)+Dca*(1.0-Sa));
- break;
- }
- if (fabs(Sca-Sa) < MagickEpsilon)
+ if ((Sca*Da+Dca*Sa) >= Sa*Da)
{
pixel=QuantumRange*gamma*(Sa*Da+Sca*(1.0-Da)+Dca*(1.0-Sa));
break;
case CopyBlackCompositeOp:
{
if (channel == BlackPixelChannel)
- pixel=(MagickRealType) GetPixelBlack(composite_image,p);
+ pixel=(MagickRealType) (QuantumRange-
+ GetPixelBlack(composite_image,p));
break;
}
case CopyBlueCompositeOp:
{
pixel=Sc+Dc;
if (pixel > QuantumRange)
- pixel-=(QuantumRange+1.0);
- pixel=gamma*(pixel*Sa*Da+Sa*Sc*(1.0-Da)+Da*Dc*(1.0-Sa));
+ pixel-=QuantumRange;
+ pixel=gamma*(Sa*Da*pixel+Sa*Sc*(1.0-Da)+Da*Dc*(1.0-Sa));
break;
}
case ModulusSubtractCompositeOp:
{
pixel=Sc-Dc;
if (pixel < 0.0)
- pixel+=(QuantumRange+1.0);
- pixel=gamma*(pixel*Sa*Da+Sa*Sc*(1.0-Da)+Da*Dc*(1.0-Sa));
+ pixel+=QuantumRange;
+ pixel=gamma*(Sa*Da*pixel+Sa*Sc*(1.0-Da)+Da*Dc*(1.0-Sa));
break;
}
case MultiplyCompositeOp:
exception);
status=MagickTrue;
if ((image->compose != CopyCompositeOp) &&
- ((image->compose != OverCompositeOp) || (image->alpha_trait == BlendPixelTrait) ||
+ ((image->compose != OverCompositeOp) ||
+ (image->alpha_trait == BlendPixelTrait) ||
(texture_image->alpha_trait == BlendPixelTrait)))
{
/*
register ssize_t
i;
- if (GetPixelMask(image,p) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
p+=GetPixelChannels(texture_image);
q+=GetPixelChannels(image);
}
for (i=0; i < (ssize_t) GetPixelChannels(texture_image); i++)
{
- PixelChannel
- channel;
-
- PixelTrait
- texture_traits,
- traits;
-
- channel=GetPixelChannelChannel(texture_image,i);
- texture_traits=GetPixelChannelTraits(texture_image,channel);
- traits=GetPixelChannelTraits(image,channel);
+ PixelChannel channel=GetPixelChannelChannel(texture_image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ PixelTrait texture_traits=GetPixelChannelTraits(texture_image,
+ channel);
if ((traits == UndefinedPixelTrait) ||
(texture_traits == UndefinedPixelTrait))
continue;