% MagickCore Methods to Import/Export Pixels %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1998 %
% %
% %
-% 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 %
}
case IndexQuantum:
{
- *q=ScaleQuantumToLongLong(ClampToQuantum(GetPixelIntensity(image,p)));
+ *q=ScaleQuantumToLongLong(ClampToQuantum(
+ GetPixelIntensity(image,p)));
break;
}
default:
}
}
-MagickExport MagickBooleanType ExportImagePixels(Image *image,
- const ssize_t x,const ssize_t y,const size_t width,const size_t height,
- const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
+MagickExport MagickBooleanType ExportImagePixels(Image *image,const ssize_t x,
+ const ssize_t y,const size_t width,const size_t height,const char *map,
+ const StorageType type,void *pixels,ExceptionInfo *exception)
{
QuantumType
*quantum_map;
%
% Rec601Luma 0.298839R' + 0.586811G' + 0.114350B'
% Rec601Luminance 0.298839R + 0.586811G + 0.114350B
-% Rec709Luma 0.21260R' + 0.71520G' + 0.07220B'
-% Rec709Luminance 0.21260R + 0.71520G + 0.07220B
-% Brightness max(R, G, B)
-% Lightness (min(R, G, B) + max(R, G, B)) / 2.0
-% RMS (R'^2 + G'^2 + B'^2) / 3.0
-% Average (R' + G' + B') / 3.0
+% Rec709Luma 0.212656R' + 0.715158G' + 0.072186B'
+% Rec709Luminance 0.212656R + 0.715158G + 0.072186B
+% Brightness max(R', G', B')
+% Lightness (min(R', G', B') + max(R', G', B')) / 2.0
+%
+% MS (R^2 + G^2 + B^2) / 3.0
+% RMS sqrt((R^2 + G^2 + B^2) / 3.0
+% Average (R + G + B') / 3.0
%
% The format of the GetPixelIntensity method is:
%
}
case LightnessPixelIntensityMethod:
{
- intensity=MagickMin(MagickMin(red,green),blue);
+ intensity=(MagickMin(MagickMin(red,green),blue)+
+ MagickMax(MagickMax(red,green),blue))/2.0;
break;
}
case MSPixelIntensityMethod:
}
case Rec601LumaPixelIntensityMethod:
{
+ if (image->colorspace == RGBColorspace)
+ {
+ red=EncodePixelGamma(red);
+ green=EncodePixelGamma(green);
+ blue=EncodePixelGamma(blue);
+ }
intensity=0.298839*red+0.586811*green+0.114350*blue;
break;
}
case Rec709LumaPixelIntensityMethod:
default:
{
- intensity=0.21260f*red+0.71520f*green+0.07220f*blue;
+ if (image->colorspace == RGBColorspace)
+ {
+ red=EncodePixelGamma(red);
+ green=EncodePixelGamma(green);
+ blue=EncodePixelGamma(blue);
+ }
+ intensity=0.212656*red+0.715158*green+0.072186*blue;
break;
}
case Rec709LuminancePixelIntensityMethod:
green=DecodePixelGamma(green);
blue=DecodePixelGamma(blue);
}
- intensity=0.21260f*red+0.71520f*green+0.07220f*blue;
+ intensity=0.212656*red+0.715158*green+0.072186*blue;
break;
}
case RMSPixelIntensityMethod:
{
quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
- "UnrecognizedPixelMap","`%s'",map);
+ "UnrecognizedStorageType","`%d'",type);
break;
}
}
beta;
/*
- Nicolas Robidoux' 12 flops (6* + 5- + 1+) refactoring of the
- computation of the standard four 1D cubic B-spline smoothing
- weights. The sampling location is assumed between the second and
- third input pixel locations, and x is the position relative to the
- second input pixel location.
+ Nicolas Robidoux' 12 flops (6* + 5- + 1+) refactoring of the computation
+ of the standard four 1D cubic B-spline smoothing weights. The sampling
+ location is assumed between the second and third input pixel locations,
+ and x is the position relative to the second input pixel location.
*/
alpha=(double) 1.0-x;
(*weights)[3]=(double) (1.0/6.0)*x*x*x;
const PixelInterpolateMethod method,const double x,const double y,
double *pixel,ExceptionInfo *exception)
{
- MagickBooleanType
- status;
-
double
alpha[16],
gamma,
pixels[16];
+ MagickBooleanType
+ status;
+
+ PixelInterpolateMethod
+ interpolate;
+
PixelTrait
traits;
x_offset,
y_offset;
- PixelInterpolateMethod
- interpolate;
-
assert(image != (Image *) NULL);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
interpolate = image->interpolate;
switch (interpolate)
{
- case AverageInterpolatePixel: /* nearest 4 neighbours */
- case Average9InterpolatePixel: /* nearest 9 neighbours */
- case Average16InterpolatePixel: /* nearest 16 neighbours */
+ case AverageInterpolatePixel: /* nearest 4 neighbours */
+ case Average9InterpolatePixel: /* nearest 9 neighbours */
+ case Average16InterpolatePixel: /* nearest 16 neighbours */
{
ssize_t
count;
status=MagickFalse;
break;
}
- count*=count; /* Number of pixels to Average */
+ count*=count; /* Number of pixels to average */
if ((traits & BlendPixelTrait) == 0)
for (i=0; i < (ssize_t) count; i++)
{
GetPixelChannels(image));
pixels[i]=alpha[i]*p[i*GetPixelChannels(image)+channel];
}
- gamma=1.0; /* number of pixels blended together (its variable) */
+ gamma=1.0; /* number of pixels blended together (its variable) */
for (i=0; i <= 1L; i++) {
if ((y-y_offset) >= 0.75)
{
pixels[0]+=pixels[1];
}
if (channel != AlphaPixelChannel)
- gamma=PerceptibleReciprocal(alpha[0]); /* (color) 1/alpha_weights */
+ gamma=PerceptibleReciprocal(alpha[0]); /* (color) 1/alpha_weights */
else
- gamma=PerceptibleReciprocal(gamma); /* (alpha) 1/number_of_pixels */
+ gamma=PerceptibleReciprocal(gamma); /* (alpha) 1/number_of_pixels */
*pixel=gamma*pixels[0];
break;
}
}
delta.x=x-x_offset;
delta.y=y-y_offset;
- luminance.x=GetPixelLuminance(image,p)-(double)
- GetPixelLuminance(image,p+3*GetPixelChannels(image));
- luminance.y=GetPixelLuminance(image,p+GetPixelChannels(image))-(double)
- GetPixelLuminance(image,p+2*GetPixelChannels(image));
+ luminance.x=GetPixelLuma(image,p)-(double)
+ GetPixelLuma(image,p+3*GetPixelChannels(image));
+ luminance.y=GetPixelLuma(image,p+GetPixelChannels(image))-(double)
+ GetPixelLuma(image,p+2*GetPixelChannels(image));
if (fabs(luminance.x) < fabs(luminance.y))
{
/*
interpolate = source->interpolate;
switch (interpolate)
{
- case AverageInterpolatePixel: /* nearest 4 neighbours */
- case Average9InterpolatePixel: /* nearest 9 neighbours */
- case Average16InterpolatePixel: /* nearest 16 neighbours */
+ case AverageInterpolatePixel: /* nearest 4 neighbours */
+ case Average9InterpolatePixel: /* nearest 9 neighbours */
+ case Average16InterpolatePixel: /* nearest 16 neighbours */
{
ssize_t
count;
status=MagickFalse;
break;
}
- count*=count; /* Number of pixels to Average */
+ count*=count; /* Number of pixels to average */
for (i=0; i < (ssize_t) GetPixelChannels(source); i++)
{
double
else
if ((y-y_offset) > 0.25)
{
- gamma=2.0; /* blend both pixels in row */
+ gamma=2.0; /* blend both pixels in row */
alpha[j]+=alpha[j+2]; /* add up alpha weights */
pixels[j]+=pixels[j+2];
}
pixels[0]+=pixels[1];
}
if ((traits & BlendPixelTrait) == 0)
- gamma=PerceptibleReciprocal(alpha[0]); /* (color) 1/alpha_weights */
+ gamma=PerceptibleReciprocal(alpha[0]); /* (color) 1/alpha_weights */
else
- gamma=PerceptibleReciprocal(gamma); /* (alpha) 1/number_of_pixels */
+ gamma=PerceptibleReciprocal(gamma); /* (alpha) 1/number_of_pixels */
SetPixelChannel(destination,channel,ClampToQuantum(gamma*pixels[0]),
pixel);
}
}
delta.x=x-x_offset;
delta.y=y-y_offset;
- luminance.x=fabs((double) (GetPixelLuminance(source,p)-
- GetPixelLuminance(source,p+3*GetPixelChannels(source))));
- luminance.y=fabs((double) (GetPixelLuminance(source,p+
- GetPixelChannels(source))-GetPixelLuminance(source,p+2*
+ luminance.x=fabs((double) (GetPixelLuma(source,p)-
+ GetPixelLuma(source,p+3*GetPixelChannels(source))));
+ luminance.y=fabs((double) (GetPixelLuma(source,p+
+ GetPixelChannels(source))-GetPixelLuma(source,p+2*
GetPixelChannels(source))));
if (luminance.x < luminance.y)
{
interpolate = image->interpolate;
switch (interpolate)
{
- case AverageInterpolatePixel: /* nearest 4 neighbours */
- case Average9InterpolatePixel: /* nearest 9 neighbours */
- case Average16InterpolatePixel: /* nearest 16 neighbours */
+ case AverageInterpolatePixel: /* nearest 4 neighbours */
+ case Average9InterpolatePixel: /* nearest 9 neighbours */
+ case Average16InterpolatePixel: /* nearest 16 neighbours */
{
ssize_t
count;
pixel->blue=0.0;
pixel->black=0.0;
pixel->alpha=0.0;
- count*=count; /* number of pixels - square of size */
+ count*=count; /* number of pixels - square of size */
for (i=0; i < (ssize_t) count; i++)
{
AlphaBlendPixelInfo(image,p,pixels,alpha);
if ((x-x_offset) > 0.25)
{
gamma*=2.0; /* blend both rows */
- alpha[0]+= alpha[1]; /* add up alpha weights */
+ alpha[0]+= alpha[1]; /* add up alpha weights */
pixels[0].red+=pixels[1].red;
pixels[0].green+=pixels[1].green;
pixels[0].blue+=pixels[1].blue;
}
delta.x=x-x_offset;
delta.y=y-y_offset;
- luminance.x=GetPixelLuminance(image,p)-(double)
- GetPixelLuminance(image,p+3*GetPixelChannels(image));
- luminance.y=GetPixelLuminance(image,p+GetPixelChannels(image))-(double)
- GetPixelLuminance(image,p+2*GetPixelChannels(image));
+ luminance.x=GetPixelLuma(image,p)-(double)
+ GetPixelLuma(image,p+3*GetPixelChannels(image));
+ luminance.y=GetPixelLuma(image,p+GetPixelChannels(image))-(double)
+ GetPixelLuma(image,p+2*GetPixelChannels(image));
AlphaBlendPixelInfo(image,p,pixels+0,alpha+0);
AlphaBlendPixelInfo(image,p+GetPixelChannels(image),pixels+1,alpha+1);
AlphaBlendPixelInfo(image,p+2*GetPixelChannels(image),pixels+2,alpha+2);
distance,
scale;
- fuzz=MagickMax(source->fuzz,(double) MagickSQ1_2)*MagickMax(
- destination->fuzz,(double) MagickSQ1_2);
+ fuzz=(double) MagickMax(source->fuzz,(MagickRealType) MagickSQ1_2)*MagickMax(
+ destination->fuzz,(MagickRealType) MagickSQ1_2);
scale=1.0;
distance=0.0;
if (source->alpha_trait == BlendPixelTrait)
if ((p->fuzz == 0.0) && (q->fuzz == 0.0))
return(IsPixelInfoEquivalent(p,q));
if (p->fuzz == 0.0)
- fuzz=MagickMax(q->fuzz,(double) MagickSQ1_2)*MagickMax(q->fuzz,MagickSQ1_2);
+ fuzz=MagickMax(q->fuzz,(MagickRealType) MagickSQ1_2)*
+ MagickMax(q->fuzz,(MagickRealType) MagickSQ1_2);
else if (q->fuzz == 0.0)
- fuzz=MagickMax(p->fuzz,(double) MagickSQ1_2)*MagickMax(p->fuzz,MagickSQ1_2);
+ fuzz=MagickMax(p->fuzz,(MagickRealType) MagickSQ1_2)*
+ MagickMax(p->fuzz,(MagickRealType) MagickSQ1_2);
else
- fuzz=MagickMax(p->fuzz,(double) MagickSQ1_2)*MagickMax(q->fuzz,MagickSQ1_2);
+ fuzz=MagickMax(p->fuzz,(MagickRealType) MagickSQ1_2)*
+ MagickMax(q->fuzz,(MagickRealType) MagickSQ1_2);
scale=1.0;
distance=0.0;
if ((p->alpha_trait == BlendPixelTrait) ||
(p->colorspace == HWBColorspace))
{
/*
- This calculates a arc distance for hue-- it should be a vector angle
- of 'S'/'W' length with 'L'/'B' forming appropriate cones. In other
- words this is a hack - Anthony.
+ This calculates a arc distance for hue-- it should be a vector
+ angle of 'S'/'W' length with 'L'/'B' forming appropriate cones.
+ In other words this is a hack - Anthony.
*/
if (fabs((double) pixel) > (QuantumRange/2))
pixel-=QuantumRange;