% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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/image.h"
#include "MagickCore/image-private.h"
#include "MagickCore/gem.h"
+#include "MagickCore/gem-private.h"
#include "MagickCore/memory_.h"
#include "MagickCore/monitor.h"
#include "MagickCore/monitor-private.h"
#include "MagickCore/quantize.h"
#include "MagickCore/quantum.h"
#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
#include "MagickCore/string_.h"
#include "MagickCore/string-private.h"
#include "MagickCore/utility.h"
} TransformPacket;
\f
/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ Forward declarations.
+*/
+static MagickBooleanType
+ TransformsRGBImage(Image *,const ColorspaceType,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
-+ R G B T r a n s f o r m I m a g e %
++ s R G B T r a n s f o r m I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% RGBTransformImage() converts the reference image from RGB to an alternate
+% sRGBTransformImage() converts the reference image from sRGB to an alternate
% colorspace. The transformation matrices are not the standard ones: the
% weights are rescaled to normalized the range of the transformed values to
% be [0..QuantumRange].
%
-% The format of the RGBTransformImage method is:
+% The format of the sRGBTransformImage method is:
%
-% MagickBooleanType RGBTransformImage(Image *image,
-% const ColorspaceType colorspace)
+% MagickBooleanType sRGBTransformImage(Image *image,
+% const ColorspaceType colorspace,EsceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o colorspace: the colorspace to transform the image to.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static inline void ConvertRGBToXYZ(const Quantum red,const Quantum green,
assert(Y != (double *) NULL);
assert(Z != (double *) NULL);
r=QuantumScale*red;
- if (r > 0.04045)
+ if (r > 0.0404482362771082)
r=pow((r+0.055)/1.055,2.4);
else
r/=12.92;
g=QuantumScale*green;
- if (g > 0.04045)
+ if (g > 0.0404482362771082)
g=pow((g+0.055)/1.055,2.4);
else
g/=12.92;
b=QuantumScale*blue;
- if (b > 0.04045)
+ if (b > 0.0404482362771082)
b=pow((b+0.055)/1.055,2.4);
else
b/=12.92;
*L=0.0;
*a=0.5;
*b=0.5;
- if ((X == 0.0) && (Y == 0.0) && (Z == 0.0))
+ if ((fabs(X) < MagickEpsilon) && (fabs(Y) < MagickEpsilon) &&
+ (fabs(Z) < MagickEpsilon))
return;
fx=LabF1(X/D50X);
fy=LabF1(Y/D50Y);
*b+=1.0;
}
-MagickExport MagickBooleanType RGBTransformImage(Image *image,
- const ColorspaceType colorspace)
+static MagickBooleanType sRGBTransformImage(Image *image,
+ const ColorspaceType colorspace,ExceptionInfo *exception)
{
-#define RGBTransformImageTag "RGBTransform/Image"
+#define sRGBTransformImageTag "RGBTransform/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
- status,
- sync;
+ status;
MagickOffsetType
progress;
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(colorspace != RGBColorspace);
+ assert(colorspace != sRGBColorspace);
assert(colorspace != TransparentColorspace);
assert(colorspace != UndefinedColorspace);
- switch (image->colorspace)
- {
- case GRAYColorspace:
- case Rec601LumaColorspace:
- case Rec709LumaColorspace:
- case RGBColorspace:
- case TransparentColorspace:
- break;
- default:
- {
- (void) TransformImageColorspace(image,image->colorspace);
- break;
- }
- }
- if (SetImageColorspace(image,colorspace) == MagickFalse)
- return(MagickFalse);
+ if (IsGrayColorspace(colorspace) != MagickFalse)
+ (void) SetImageColorspace(image,sRGBColorspace,exception);
+ else
+ if (SetImageColorspace(image,colorspace,exception) == MagickFalse)
+ return(MagickFalse);
status=MagickTrue;
progress=0;
- exception=(&image->exception);
switch (colorspace)
{
case CMYColorspace:
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
GetPixelInfo(image,&zero);
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ MagickBooleanType
+ sync;
+
PixelInfo
pixel;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
pixel=zero;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetPixelInfo(image,q,&pixel);
+ GetPixelInfoPixel(image,q,&pixel);
ConvertRGBToCMYK(&pixel);
- SetPixelPixelInfo(image,&pixel,q);
+ SetPixelInfoPixel(image,&pixel,q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
hue,
saturation;
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
brightness=0.0;
for (x=0; x < (ssize_t) image->columns; x++)
{
- ConvertRGBToHSB(GetPixelRed(image,q),GetPixelGreen(image,q),
- GetPixelBlue(image,q),&hue,&saturation,&brightness);
+ ConvertRGBToHSB((double) GetPixelRed(image,q),
+ (double) GetPixelGreen(image,q),(double) GetPixelBlue(image,q),
+ &hue,&saturation,&brightness);
SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange*
hue),q);
SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange*
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
lightness,
saturation;
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
lightness=0.0;
for (x=0; x < (ssize_t) image->columns; x++)
{
- ConvertRGBToHSL(GetPixelRed(image,q),GetPixelGreen(image,q),
- GetPixelBlue(image,q),&hue,&saturation,&lightness);
+ ConvertRGBToHSL((double) GetPixelRed(image,q),(double)
+ GetPixelGreen(image,q),(double) GetPixelBlue(image,q),
+ &hue,&saturation,&lightness);
SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange*
hue),q);
SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange*
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
hue,
whiteness;
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
blackness=0.0;
for (x=0; x < (ssize_t) image->columns; x++)
{
- ConvertRGBToHWB(GetPixelRed(image,q),GetPixelGreen(image,q),
- GetPixelBlue(image,q),&hue,&whiteness,&blackness);
+ ConvertRGBToHWB((double) GetPixelRed(image,q),(double)
+ GetPixelGreen(image,q),(double) GetPixelBlue(image,q),
+ &hue,&whiteness,&blackness);
SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange*
hue),q);
SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange*
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
Y,
Z;
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
*/
density=DisplayGamma;
gamma=DisplayGamma;
- value=GetImageProperty(image,"gamma");
+ value=GetImageProperty(image,"gamma",exception);
if (value != (const char *) NULL)
- gamma=1.0/InterpretLocaleValue(value,(char **) NULL) != 0.0 ?
- InterpretLocaleValue(value,(char **) NULL) : 1.0;
+ gamma=1.0/fabs(StringToDouble(value,(char **) NULL)) >= MagickEpsilon ?
+ StringToDouble(value,(char **) NULL) : 1.0;
film_gamma=FilmGamma;
- value=GetImageProperty(image,"film-gamma");
+ value=GetImageProperty(image,"film-gamma",exception);
if (value != (const char *) NULL)
- film_gamma=InterpretLocaleValue(value,(char **) NULL);
+ film_gamma=StringToDouble(value,(char **) NULL);
reference_black=ReferenceBlack;
- value=GetImageProperty(image,"reference-black");
+ value=GetImageProperty(image,"reference-black",exception);
if (value != (const char *) NULL)
- reference_black=InterpretLocaleValue(value,(char **) NULL);
+ reference_black=StringToDouble(value,(char **) NULL);
reference_white=ReferenceWhite;
- value=GetImageProperty(image,"reference-white");
+ value=GetImageProperty(image,"reference-white",exception);
if (value != (const char *) NULL)
- reference_white=InterpretLocaleValue(value,(char **) NULL);
+ reference_white=StringToDouble(value,(char **) NULL);
logmap=(Quantum *) AcquireQuantumMemory((size_t) MaxMap+1UL,
sizeof(*logmap));
if (logmap == (Quantum *) NULL)
black=pow(10.0,(reference_black-reference_white)*(gamma/density)*
0.002/film_gamma);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
logmap[i]=ScaleMapToQuantum((MagickRealType) (MaxMap*(reference_white+
log10(black+((MagickRealType) i/MaxMap)*(1.0-black))/((gamma/density)*
0.002/film_gamma))/1024.0));
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ MagickBooleanType
+ sync;
+
register ssize_t
x;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
G = 0.29900*R+0.58700*G+0.11400*B
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
G = 0.21260*R+0.71520*G+0.07220*B
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
}
break;
}
- case sRGBColorspace:
+ case RGBColorspace:
{
/*
- Linear sRGB to nonlinear RGB (http://www.w3.org/Graphics/Color/sRGB):
-
- R = 1.0*R+0.0*G+0.0*B
- G = 0.0*R+0.1*G+0.0*B
- B = 0.0*R+0.0*G+1.0*B
+ Nonlinear sRGB to linear RGB.
+ Mostly removal of a gamma function, but with a linear component
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
v;
v=(MagickRealType) i/(MagickRealType) MaxMap;
- if (((MagickRealType) i/(MagickRealType) MaxMap) <= 0.04045f)
+ if (((MagickRealType) i/(MagickRealType) MaxMap) <= 0.0404482362771082f)
v/=12.92f;
else
v=(MagickRealType) pow((((double) i/MaxMap)+0.055)/1.055,2.4);
Z = 0.0193339*R+0.1191920*G+0.9503041*B
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
break;
}
case YUVColorspace:
- default:
{
/*
Initialize YUV tables:
primary_info.y=(double) (MaxMap+1.0)/2.0;
primary_info.z=(double) (MaxMap+1.0)/2.0;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
}
break;
}
+ default:
+ {
+ /*
+ Linear conversion tables.
+ */
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
+#endif
+ for (i=0; i <= (ssize_t) MaxMap; i++)
+ {
+ x_map[i].x=(MagickRealType) i;
+ y_map[i].x=0.0f;
+ z_map[i].x=0.0f;
+ x_map[i].y=0.0f;
+ y_map[i].y=(MagickRealType) i;
+ z_map[i].y=0.0f;
+ x_map[i].z=0.0f;
+ y_map[i].z=0.0f;
+ z_map[i].z=(MagickRealType) i;
+ }
+ break;
+ }
}
/*
Convert from RGB.
/*
Convert DirectClass image.
*/
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ MagickBooleanType
+ sync;
+
PixelInfo
pixel;
- register ssize_t
- x;
-
register Quantum
*restrict q;
- register size_t
+ register ssize_t
+ x;
+
+ register unsigned int
blue,
green,
red;
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_RGBTransformImage)
+ #pragma omp critical (MagickCore_sRGBTransformImage)
#endif
- proceed=SetImageProgress(image,RGBTransformImageTag,progress++,
+ proceed=SetImageProgress(image,sRGBTransformImageTag,progress++,
image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
case PseudoClass:
{
- register size_t
+ register unsigned int
blue,
green,
red;
/*
Convert PseudoClass image.
*/
- image_view=AcquireCacheView(image);
for (i=0; i < (ssize_t) image->colors; i++)
{
PixelInfo
pixel;
- red=ScaleQuantumToMap(image->colormap[i].red);
- green=ScaleQuantumToMap(image->colormap[i].green);
- blue=ScaleQuantumToMap(image->colormap[i].blue);
+ red=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].red));
+ green=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].green));
+ blue=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].blue));
pixel.red=x_map[red].x+y_map[green].x+z_map[blue].x+primary_info.x;
pixel.green=x_map[red].y+y_map[green].y+z_map[blue].y+primary_info.y;
pixel.blue=x_map[red].z+y_map[green].z+z_map[blue].z+primary_info.z;
- image->colormap[i].red=ScaleMapToQuantum(pixel.red);
- image->colormap[i].green=ScaleMapToQuantum(pixel.green);
- image->colormap[i].blue=ScaleMapToQuantum(pixel.blue);
+ image->colormap[i].red=(double) ScaleMapToQuantum(pixel.red);
+ image->colormap[i].green=(double) ScaleMapToQuantum(pixel.green);
+ image->colormap[i].blue=(double) ScaleMapToQuantum(pixel.blue);
}
- image_view=DestroyCacheView(image_view);
- (void) SyncImage(image);
+ (void) SyncImage(image,exception);
break;
}
}
z_map=(TransformPacket *) RelinquishMagickMemory(z_map);
y_map=(TransformPacket *) RelinquishMagickMemory(y_map);
x_map=(TransformPacket *) RelinquishMagickMemory(x_map);
- if (SetImageColorspace(image,colorspace) == MagickFalse)
+ if (SetImageColorspace(image,colorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
% The format of the SetImageColorspace method is:
%
% MagickBooleanType SetImageColorspace(Image *image,
-% const ColorspaceType colorspace)
+% const ColorspaceType colorspace,ExceptiionInfo *exception)
%
% A description of each parameter follows:
%
%
% o colorspace: the colorspace.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType SetImageColorspace(Image *image,
- const ColorspaceType colorspace)
+ const ColorspaceType colorspace,ExceptionInfo *exception)
{
image->colorspace=colorspace;
- return(MagickTrue);
+ image->rendering_intent=UndefinedIntent;
+ image->gamma=1.000f;
+ ResetMagickMemory(&image->chromaticity,0,sizeof(image->chromaticity));
+ if (IssRGBColorspace(colorspace) != MagickFalse)
+ {
+ image->rendering_intent=PerceptualIntent;
+ image->gamma=1.000f/2.200f;
+ image->chromaticity.red_primary.x=0.6400f;
+ image->chromaticity.red_primary.y=0.3300f;
+ image->chromaticity.red_primary.z=0.0300f;
+ image->chromaticity.green_primary.x=0.3000f;
+ image->chromaticity.green_primary.y=0.6000f;
+ image->chromaticity.green_primary.z=0.1000f;
+ image->chromaticity.blue_primary.x=0.1500f;
+ image->chromaticity.blue_primary.y=0.0600f;
+ image->chromaticity.blue_primary.z=0.7900f;
+ image->chromaticity.white_point.x=0.3127f;
+ image->chromaticity.white_point.y=0.3290f;
+ image->chromaticity.white_point.z=0.3583f;
+ }
+ return(SyncImagePixelCache(image,exception));
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% TransformImageColorspace() transforms an image colorspace.
+% TransformImageColorspace() transforms an image colorspace, changing the
+% image data to reflect the new colorspace.
%
% The format of the TransformImageColorspace method is:
%
% MagickBooleanType TransformImageColorspace(Image *image,
-% const ColorspaceType colorspace)
+% const ColorspaceType colorspace,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o colorspace: the colorspace.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType TransformImageColorspace(Image *image,
- const ColorspaceType colorspace)
+ const ColorspaceType colorspace,ExceptionInfo *exception)
{
MagickBooleanType
status;
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (colorspace == UndefinedColorspace)
- {
- if (SetImageColorspace(image,colorspace) == MagickFalse)
- return(MagickFalse);
- return(MagickTrue);
- }
+ return(SetImageColorspace(image,colorspace,exception));
if (image->colorspace == colorspace)
- return(MagickTrue);
- if ((colorspace == RGBColorspace) || (colorspace == TransparentColorspace))
- return(TransformRGBImage(image,image->colorspace));
+ return(MagickTrue); /* same colorspace: no op */
+ /*
+ Convert the reference image from an alternate colorspace to sRGB.
+ */
+ if (IssRGBColorspace(colorspace) != MagickFalse)
+ return(TransformsRGBImage(image,colorspace,exception));
status=MagickTrue;
- if ((image->colorspace != RGBColorspace) &&
- (image->colorspace != TransparentColorspace) &&
- (image->colorspace != GRAYColorspace))
- status=TransformRGBImage(image,image->colorspace);
- if (RGBTransformImage(image,colorspace) == MagickFalse)
+ if ((IsRGBColorspace(image->colorspace) != MagickFalse) ||
+ (IsGrayColorspace(image->colorspace) != MagickFalse))
+ status=TransformsRGBImage(image,sRGBColorspace,exception);
+ if (status == MagickFalse)
+ return(status);
+ if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ status=TransformsRGBImage(image,image->colorspace,exception);
+ if (status == MagickFalse)
+ return(status);
+ /*
+ Convert the reference image from sRGB to an alternate colorspace.
+ */
+ if (sRGBTransformImage(image,colorspace,exception) == MagickFalse)
status=MagickFalse;
return(status);
}
% %
% %
% %
-+ T r a n s f o r m R G B I m a g e %
++ T r a n s f o r m s R G B I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% TransformRGBImage() converts the reference image from an alternate
-% colorspace to RGB. The transformation matrices are not the standard ones:
-% the weights are rescaled to normalize the range of the transformed values to
-% be [0..QuantumRange].
+% TransformsRGBImage() converts the reference image from an alternate
+% colorspace to sRGB. The transformation matrices are not the standard ones:
+% the weights are rescaled to normalize the range of the transformed values
+% to be [0..QuantumRange].
%
-% The format of the TransformRGBImage method is:
+% The format of the TransformsRGBImage method is:
%
-% MagickBooleanType TransformRGBImage(Image *image,
-% const ColorspaceType colorspace)
+% MagickBooleanType TransformsRGBImage(Image *image,
+% const ColorspaceType colorspace,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o colorspace: the colorspace to transform the image to.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static double LabF2(double alpha)
r=3.2404542*x-1.5371385*y-0.4985314*z;
g=(-0.9692660*x+1.8760108*y+0.0415560*z);
b=0.0556434*x-0.2040259*y+1.0572252*z;
- if (r > 0.0031308)
+ if (r > 0.00313066844250063)
r=1.055*pow(r,1.0/2.4)-0.055;
else
r*=12.92;
- if (g > 0.0031308)
+ if (g > 0.00313066844250063)
g=1.055*pow(g,1.0/2.4)-0.055;
else
g*=12.92;
- if (b > 0.0031308)
+ if (b > 0.00313066844250063)
b=1.055*pow(b,1.0/2.4)-0.055;
else
b*=12.92;
(QuantumRange-pixel->black)+pixel->black);
}
-MagickExport MagickBooleanType TransformRGBImage(Image *image,
- const ColorspaceType colorspace)
+static MagickBooleanType TransformsRGBImage(Image *image,
+ const ColorspaceType colorspace,ExceptionInfo *exception)
{
#define D50X (0.9642)
#define D50Y (1.0)
#define D50Z (0.8249)
-#define TransformRGBImageTag "Transform/Image"
+#define TransformsRGBImageTag "Transform/Image"
#if !defined(MAGICKCORE_HDRI_SUPPORT)
static const float
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- switch (colorspace)
- {
- case GRAYColorspace:
- case Rec601LumaColorspace:
- case Rec709LumaColorspace:
- case RGBColorspace:
- case TransparentColorspace:
- case UndefinedColorspace:
- return(MagickTrue);
- default:
- break;
- }
status=MagickTrue;
progress=0;
- exception=(&image->exception);
- switch (colorspace)
+ switch (image->colorspace)
{
case CMYColorspace:
{
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
GetPixelInfo(image,&zero);
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
pixel=zero;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetPixelInfo(image,q,&pixel);
+ GetPixelInfoPixel(image,q,&pixel);
ConvertCMYKToRGB(&pixel);
- SetPixelPixelInfo(image,&pixel,q);
+ SetPixelInfoPixel(image,&pixel,q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
- Quantum
+ double
blue,
green,
red;
saturation=(double) (QuantumScale*GetPixelGreen(image,q));
brightness=(double) (QuantumScale*GetPixelBlue(image,q));
ConvertHSBToRGB(hue,saturation,brightness,&red,&green,&blue);
- SetPixelRed(image,red,q);
- SetPixelGreen(image,green,q);
- SetPixelBlue(image,blue,q);
+ SetPixelRed(image,ClampToQuantum(red),q);
+ SetPixelGreen(image,ClampToQuantum(green),q);
+ SetPixelBlue(image,ClampToQuantum(blue),q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
- Quantum
+ double
blue,
green,
red;
saturation=(double) (QuantumScale*GetPixelGreen(image,q));
lightness=(double) (QuantumScale*GetPixelBlue(image,q));
ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
- SetPixelRed(image,red,q);
- SetPixelGreen(image,green,q);
- SetPixelBlue(image,blue,q);
+ SetPixelRed(image,ClampToQuantum(red),q);
+ SetPixelGreen(image,ClampToQuantum(green),q);
+ SetPixelBlue(image,ClampToQuantum(blue),q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
- Quantum
+ double
blue,
green,
red;
whiteness=(double) (QuantumScale*GetPixelGreen(image,q));
blackness=(double) (QuantumScale*GetPixelBlue(image,q));
ConvertHWBToRGB(hue,whiteness,blackness,&red,&green,&blue);
- SetPixelRed(image,red,q);
- SetPixelGreen(image,green,q);
- SetPixelBlue(image,blue,q);
+ SetPixelRed(image,ClampToQuantum(red),q);
+ SetPixelGreen(image,ClampToQuantum(green),q);
+ SetPixelBlue(image,ClampToQuantum(blue),q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
if (image->storage_class == PseudoClass)
{
- if (SyncImage(image) == MagickFalse)
+ if (SyncImage(image,exception) == MagickFalse)
return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
}
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
*/
density=DisplayGamma;
gamma=DisplayGamma;
- value=GetImageProperty(image,"gamma");
+ value=GetImageProperty(image,"gamma",exception);
if (value != (const char *) NULL)
- gamma=1.0/InterpretLocaleValue(value,(char **) NULL) != 0.0 ?
- InterpretLocaleValue(value,(char **) NULL) : 1.0;
+ gamma=1.0/fabs(StringToDouble(value,(char **) NULL)) >=
+ MagickEpsilon ? StringToDouble(value,(char **) NULL) : 1.0;
film_gamma=FilmGamma;
- value=GetImageProperty(image,"film-gamma");
+ value=GetImageProperty(image,"film-gamma",exception);
if (value != (const char *) NULL)
- film_gamma=InterpretLocaleValue(value,(char **) NULL);
+ film_gamma=StringToDouble(value,(char **) NULL);
reference_black=ReferenceBlack;
- value=GetImageProperty(image,"reference-black");
+ value=GetImageProperty(image,"reference-black",exception);
if (value != (const char *) NULL)
- reference_black=InterpretLocaleValue(value,(char **) NULL);
+ reference_black=StringToDouble(value,(char **) NULL);
reference_white=ReferenceWhite;
- value=GetImageProperty(image,"reference-white");
+ value=GetImageProperty(image,"reference-white",exception);
if (value != (const char *) NULL)
- reference_white=InterpretLocaleValue(value,(char **) NULL);
+ reference_white=StringToDouble(value,(char **) NULL);
logmap=(Quantum *) AcquireQuantumMemory((size_t) MaxMap+1UL,
sizeof(*logmap));
if (logmap == (Quantum *) NULL)
(gamma/density)*0.002/film_gamma)-black));
for ( ; i <= (ssize_t) MaxMap; i++)
logmap[i]=(Quantum) QuantumRange;
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
image_view=DestroyCacheView(image_view);
logmap=(Quantum *) RelinquishMagickMemory(logmap);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(status);
}
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
- switch (colorspace)
+ switch (image->colorspace)
{
case OHTAColorspace:
{
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
}
break;
}
- case sRGBColorspace:
+ case RGBColorspace:
{
/*
- Nonlinear sRGB to linear RGB.
+ Nonlinear sRGB to linear RGB (http://www.w3.org/Graphics/Color/sRGB):
R = 1.0*R+0.0*G+0.0*B
G = 0.0*R+1.0*G+0.0*B
B = 0.0*R+0.0*G+1.0*B
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
- x_map[i].x=1.0f*(MagickRealType) i;
- y_map[i].x=0.0f*(MagickRealType) i;
- z_map[i].x=0.0f*(MagickRealType) i;
- x_map[i].y=0.0f*(MagickRealType) i;
- y_map[i].y=1.0f*(MagickRealType) i;
- z_map[i].y=0.0f*(MagickRealType) i;
- x_map[i].z=0.0f*(MagickRealType) i;
- y_map[i].z=0.0f*(MagickRealType) i;
- z_map[i].z=1.0f*(MagickRealType) i;
+ MagickRealType
+ v;
+
+ v=(MagickRealType) i/(MagickRealType) MaxMap;
+ if (((MagickRealType) i/(MagickRealType) MaxMap) <= 0.00313066844250063)
+ v*=12.92f;
+ else
+ v=(MagickRealType) (1.055*pow((double) i/MaxMap,1.0/2.4)-0.055);
+ x_map[i].x=1.0f*MaxMap*v;
+ y_map[i].x=0.0f*MaxMap*v;
+ z_map[i].x=0.0f*MaxMap*v;
+ x_map[i].y=0.0f*MaxMap*v;
+ y_map[i].y=1.0f*MaxMap*v;
+ z_map[i].y=0.0f*MaxMap*v;
+ x_map[i].z=0.0f*MaxMap*v;
+ y_map[i].z=0.0f*MaxMap*v;
+ z_map[i].z=1.0f*MaxMap*v;
}
break;
}
B = 0.0556434*X-0.2040259*Y+1.057225*Z
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
YCC is scaled by 1.3584. C1 zero is 156 and C2 is at 137.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
break;
}
case YUVColorspace:
- default:
{
/*
Initialize YUV tables:
through QuantumRange.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i <= (ssize_t) MaxMap; i++)
{
}
break;
}
+ default:
+ {
+ /*
+ Linear conversion tables.
+ */
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp parallel for schedule(static) \
+ dynamic_number_threads(image->columns,1,1)
+#endif
+ for (i=0; i <= (ssize_t) MaxMap; i++)
+ {
+ x_map[i].x=(MagickRealType) i;
+ y_map[i].x=0.0f;
+ z_map[i].x=0.0f;
+ x_map[i].y=0.0f;
+ y_map[i].y=(MagickRealType) i;
+ z_map[i].y=0.0f;
+ x_map[i].z=0.0f;
+ y_map[i].z=0.0f;
+ z_map[i].z=(MagickRealType) i;
+ }
+ break;
+ }
}
/*
Convert to RGB.
/*
Convert DirectClass image.
*/
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
#endif
break;
}
- case sRGBColorspace:
+ case RGBColorspace:
{
- if ((QuantumScale*pixel.red) <= 0.0031308)
+ if ((QuantumScale*pixel.red) <= 0.00313066844250063)
pixel.red*=12.92f;
else
- pixel.red=(MagickRealType) QuantumRange*(1.055*
- pow(QuantumScale*pixel.red,(1.0/2.4))-0.055);
- if ((QuantumScale*pixel.green) <= 0.0031308)
+ pixel.red=(MagickRealType) QuantumRange*(1.055*pow(
+ QuantumScale*pixel.red,(1.0/2.4))-0.055);
+ if ((QuantumScale*pixel.green) <= 0.00313066844250063)
pixel.green*=12.92f;
else
- pixel.green=(MagickRealType) QuantumRange*(1.055*
- pow(QuantumScale*pixel.green,(1.0/2.4))-0.055);
- if ((QuantumScale*pixel.blue) <= 0.0031308)
+ pixel.green=(MagickRealType) QuantumRange*(1.055*pow(
+ QuantumScale*pixel.green,(1.0/2.4))-0.055);
+ if ((QuantumScale*pixel.blue) <= 0.00313066844250063)
pixel.blue*=12.92f;
else
- pixel.blue=(MagickRealType) QuantumRange*(1.055*
- pow(QuantumScale*pixel.blue,(1.0/2.4))-0.055);
- break;
+ pixel.blue=(MagickRealType) QuantumRange*(1.055*pow(
+ QuantumScale*pixel.blue,(1.0/2.4))-0.055);
}
default:
break;
}
- SetPixelRed(image,ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.red),q);
- SetPixelGreen(image,ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.green),q);
- SetPixelBlue(image,ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.blue),q);
+ SetPixelRed(image,ScaleMapToQuantum(pixel.red),q);
+ SetPixelGreen(image,ScaleMapToQuantum(pixel.green),q);
+ SetPixelBlue(image,ScaleMapToQuantum(pixel.blue),q);
q+=GetPixelChannels(image);
}
sync=SyncCacheViewAuthenticPixels(image_view,exception);
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_TransformRGBImage)
+ #pragma omp critical (MagickCore_TransformsRGBImage)
#endif
- proceed=SetImageProgress(image,TransformRGBImageTag,progress++,
+ proceed=SetImageProgress(image,TransformsRGBImageTag,progress++,
image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
/*
Convert PseudoClass image.
*/
- image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status) \
+ dynamic_number_threads(image->columns,1,1)
#endif
for (i=0; i < (ssize_t) image->colors; i++)
{
green,
red;
- red=ScaleQuantumToMap(image->colormap[i].red);
- green=ScaleQuantumToMap(image->colormap[i].green);
- blue=ScaleQuantumToMap(image->colormap[i].blue);
+ red=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].red));
+ green=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].green));
+ blue=ScaleQuantumToMap(ClampToQuantum(image->colormap[i].blue));
pixel.red=x_map[red].x+y_map[green].x+z_map[blue].x;
pixel.green=x_map[red].y+y_map[green].y+z_map[blue].y;
pixel.blue=x_map[red].z+y_map[green].z+z_map[blue].z;
case YCCColorspace:
{
#if !defined(MAGICKCORE_HDRI_SUPPORT)
- image->colormap[i].red=(Quantum) (QuantumRange*YCCMap[
- RoundToYCC(1024.0*QuantumScale*pixel.red)]);
- image->colormap[i].green=(Quantum) (QuantumRange*YCCMap[
- RoundToYCC(1024.0*QuantumScale*pixel.green)]);
- image->colormap[i].blue=(Quantum) (QuantumRange*YCCMap[
- RoundToYCC(1024.0*QuantumScale*pixel.blue)]);
+ pixel.red=QuantumRange*YCCMap[RoundToYCC(1024.0*QuantumScale*
+ pixel.red)];
+ pixel.green=QuantumRange*YCCMap[RoundToYCC(1024.0*QuantumScale*
+ pixel.green)];
+ pixel.blue=QuantumRange*YCCMap[RoundToYCC(1024.0*QuantumScale*
+ pixel.blue)];
#endif
break;
}
- case sRGBColorspace:
+ case RGBColorspace:
{
- if ((QuantumScale*pixel.red) <= 0.0031308)
+ if ((QuantumScale*pixel.red) <= 0.00313066844250063)
pixel.red*=12.92f;
else
- pixel.red=(MagickRealType) QuantumRange*(1.055*pow(QuantumScale*
- pixel.red,(1.0/2.4))-0.055);
- if ((QuantumScale*pixel.green) <= 0.0031308)
+ pixel.red=(MagickRealType) QuantumRange*(1.055*
+ pow(QuantumScale*pixel.red,(1.0/2.4))-0.055);
+ if ((QuantumScale*pixel.green) <= 0.00313066844250063)
pixel.green*=12.92f;
else
- pixel.green=(MagickRealType) QuantumRange*(1.055*pow(QuantumScale*
- pixel.green,(1.0/2.4))-0.055);
- if ((QuantumScale*pixel.blue) <= 0.0031308)
+ pixel.green=(MagickRealType) QuantumRange*(1.055*
+ pow(QuantumScale*pixel.green,(1.0/2.4))-0.055);
+ if ((QuantumScale*pixel.blue) <= 0.00313066844250063)
pixel.blue*=12.92f;
else
- pixel.blue=(MagickRealType) QuantumRange*(1.055*pow(QuantumScale*
- pixel.blue,(1.0/2.4))-0.055);
+ pixel.blue=(MagickRealType) QuantumRange*(1.055*
+ pow(QuantumScale*pixel.blue,(1.0/2.4))-0.055);
}
default:
- {
- image->colormap[i].red=ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.red);
- image->colormap[i].green=ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.green);
- image->colormap[i].blue=ScaleMapToQuantum((MagickRealType) MaxMap*
- QuantumScale*pixel.blue);
break;
- }
}
+ image->colormap[i].red=(double) ScaleMapToQuantum(pixel.red);
+ image->colormap[i].green=(double) ScaleMapToQuantum(pixel.green);
+ image->colormap[i].blue=(double) ScaleMapToQuantum(pixel.blue);
}
- image_view=DestroyCacheView(image_view);
- (void) SyncImage(image);
+ (void) SyncImage(image,exception);
break;
}
}
z_map=(TransformPacket *) RelinquishMagickMemory(z_map);
y_map=(TransformPacket *) RelinquishMagickMemory(y_map);
x_map=(TransformPacket *) RelinquishMagickMemory(x_map);
- if (SetImageColorspace(image,RGBColorspace) == MagickFalse)
+ if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
return(MagickFalse);
return(MagickTrue);
}