continue;
for (x=0; x < (ssize_t) image->columns; x++)
{
- while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
+ register ssize_t
+ i;
+
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- MagickStatusType
- status;
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if (traits == UndefinedPixelTrait)
+ continue;
+ while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
+ {
+ MagickStatusType
+ status;
- QuantumAny
- range;
+ QuantumAny
+ range;
- status=0;
- range=GetQuantumRange(current_depth[id]);
- if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
- status|=GetPixelRed(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelRed(image,p),range),range);
- if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
- status|=GetPixelGreen(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelGreen(image,p),range),range);
- if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
- status|=GetPixelBlue(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelBlue(image,p),range),range);
- if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
- (image->matte != MagickFalse))
- status|=GetPixelAlpha(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelAlpha(image,p),range),range);
- if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
- (image->colorspace == CMYKColorspace))
- status|=GetPixelBlack(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelBlack(image,p),range),range);
- if (status == 0)
- break;
- current_depth[id]++;
+ status=0;
+ range=GetQuantumRange(current_depth[id]);
+ status|=p[i] != ScaleAnyToQuantum(ScaleQuantumToAny(p[i],range),
+ range);
+ if (status == 0)
+ break;
+ current_depth[id]++;
+ }
}
p+=GetPixelChannels(image);
}
%
% The format of the SetImageDepth method is:
%
-% MagickBooleanType SetImageDepth(Image *image,const size_t depth)
-% MagickBooleanType SetImageDepth(Image *image,
-% const ChannelType channel,const size_t depth)
+% MagickBooleanType SetImageDepth(Image *image,const size_t depth,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o depth: the image depth.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType SetImageDepth(Image *image,
- const size_t depth)
+ const size_t depth,ExceptionInfo *exception)
{
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(image->signature == MagickSignature);
- if (GetImageDepth(image,&image->exception) <= (size_t)
+ if (GetImageDepth(image,exception) <= (size_t)
MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
{
image->depth=depth;
*/
status=MagickTrue;
range=GetQuantumRange(depth);
- exception=(&image->exception);
image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
if (status == MagickFalse)
continue;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
- exception);
+ q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
{
status=MagickFalse;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
- if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
- SetPixelRed(image,ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelRed(image,q),range),range),q);
- if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
- SetPixelGreen(image,ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelGreen(image,q),range),range),q);
- if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
- SetPixelBlue(image,ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelBlue(image,q),range),range),q);
- if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
- (image->colorspace == CMYKColorspace))
- SetPixelBlack(image,ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelBlack(image,q),range),range),q);
- if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
- (image->matte != MagickFalse))
- SetPixelAlpha(image,ScaleAnyToQuantum(ScaleQuantumToAny(
- GetPixelAlpha(image,q),range),range),q);
+ register ssize_t
+ i;
+
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if (traits == UndefinedPixelTrait)
+ continue;
+ q[i]=ScaleAnyToQuantum(ScaleQuantumToAny(q[i],range),range);
+ }
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
static MagickBooleanType
AssignImageColors(Image *,CubeInfo *,ExceptionInfo *),
ClassifyImageColors(CubeInfo *,const Image *,ExceptionInfo *),
- DitherImage(Image *,CubeInfo *),
+ DitherImage(Image *,CubeInfo *,ExceptionInfo *),
SetGrayscaleImage(Image *,ExceptionInfo *);
static size_t
*/
if ((cube_info->quantize_info->dither != MagickFalse) &&
(cube_info->quantize_info->dither_method != NoDitherMethod))
- (void) DitherImage(image,cube_info);
+ (void) DitherImage(image,cube_info,exception);
else
{
CacheView
status;
status=MagickTrue;
- exception=(&image->exception);
image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
image_view=DestroyCacheView(image_view);
}
if (cube_info->quantize_info->measure_error != MagickFalse)
- (void) GetImageQuantizeError(image);
+ (void) GetImageQuantizeError(image,exception);
if ((cube_info->quantize_info->number_colors == 2) &&
(cube_info->quantize_info->colorspace == GRAYColorspace))
{
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- if (IsPaletteImage(image,&image->exception) == MagickFalse)
+ if (IsPaletteImage(image,exception) == MagickFalse)
return(MagickFalse);
GetQuantizeInfo(&quantize_info);
quantize_info.number_colors=image->colors;
%
% The format of the DitherImage method is:
%
-% MagickBooleanType DitherImage(Image *image,CubeInfo *cube_info)
+% MagickBooleanType DitherImage(Image *image,CubeInfo *cube_info,
+% ExceptionInfo *exception)
%
% A description of each parameter follows.
%
%
% o cube_info: A pointer to the Cube structure.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static RealPixelInfo **DestroyPixelThreadSet(RealPixelInfo **pixels)
return(offset);
}
-static MagickBooleanType FloydSteinbergDither(Image *image,CubeInfo *cube_info)
+static MagickBooleanType FloydSteinbergDither(Image *image,CubeInfo *cube_info,
+ ExceptionInfo *exception)
{
#define DitherImageTag "Dither/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
pixels=AcquirePixelThreadSet(image->columns);
if (pixels == (RealPixelInfo **) NULL)
return(MagickFalse);
- exception=(&image->exception);
status=MagickTrue;
image_view=AcquireCacheView(image);
for (y=0; y < (ssize_t) image->rows; y++)
}
static MagickBooleanType
- RiemersmaDither(Image *,CacheView *,CubeInfo *,const unsigned int);
+ RiemersmaDither(Image *,CacheView *,CubeInfo *,const unsigned int,
+ ExceptionInfo *exception);
static void Riemersma(Image *image,CacheView *image_view,CubeInfo *cube_info,
- const size_t level,const unsigned int direction)
+ const size_t level,const unsigned int direction,ExceptionInfo *exception)
{
if (level == 1)
switch (direction)
{
case WestGravity:
{
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
break;
}
case EastGravity:
{
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
break;
}
case NorthGravity:
{
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
break;
}
case SouthGravity:
{
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
break;
}
default:
{
case WestGravity:
{
- Riemersma(image,image_view,cube_info,level-1,NorthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
- Riemersma(image,image_view,cube_info,level-1,WestGravity);
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
- Riemersma(image,image_view,cube_info,level-1,WestGravity);
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
- Riemersma(image,image_view,cube_info,level-1,SouthGravity);
+ Riemersma(image,image_view,cube_info,level-1,NorthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,WestGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,WestGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,SouthGravity,
+ exception);
break;
}
case EastGravity:
{
- Riemersma(image,image_view,cube_info,level-1,SouthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
- Riemersma(image,image_view,cube_info,level-1,EastGravity);
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
- Riemersma(image,image_view,cube_info,level-1,EastGravity);
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
- Riemersma(image,image_view,cube_info,level-1,NorthGravity);
+ Riemersma(image,image_view,cube_info,level-1,SouthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,EastGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,EastGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,NorthGravity,
+ exception);
break;
}
case NorthGravity:
{
- Riemersma(image,image_view,cube_info,level-1,WestGravity);
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
- Riemersma(image,image_view,cube_info,level-1,NorthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,EastGravity);
- Riemersma(image,image_view,cube_info,level-1,NorthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
- Riemersma(image,image_view,cube_info,level-1,EastGravity);
+ Riemersma(image,image_view,cube_info,level-1,WestGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,NorthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,EastGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,NorthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,EastGravity,
+ exception);
break;
}
case SouthGravity:
{
- Riemersma(image,image_view,cube_info,level-1,EastGravity);
- (void) RiemersmaDither(image,image_view,cube_info,NorthGravity);
- Riemersma(image,image_view,cube_info,level-1,SouthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,WestGravity);
- Riemersma(image,image_view,cube_info,level-1,SouthGravity);
- (void) RiemersmaDither(image,image_view,cube_info,SouthGravity);
- Riemersma(image,image_view,cube_info,level-1,WestGravity);
+ Riemersma(image,image_view,cube_info,level-1,EastGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,NorthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,SouthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,WestGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,SouthGravity,
+ exception);
+ (void) RiemersmaDither(image,image_view,cube_info,SouthGravity,
+ exception);
+ Riemersma(image,image_view,cube_info,level-1,WestGravity,
+ exception);
break;
}
default:
}
static MagickBooleanType RiemersmaDither(Image *image,CacheView *image_view,
- CubeInfo *cube_info,const unsigned int direction)
+ CubeInfo *cube_info,const unsigned int direction,ExceptionInfo *exception)
{
#define DitherImageTag "Dither/Image"
if ((p->x >= 0) && (p->x < (ssize_t) image->columns) &&
(p->y >= 0) && (p->y < (ssize_t) image->rows))
{
- ExceptionInfo
- *exception;
-
register Quantum
*restrict q;
/*
Distribute error.
*/
- exception=(&image->exception);
q=GetCacheViewAuthenticPixels(image_view,p->x,p->y,1,1,exception);
if (q == (Quantum *) NULL)
return(MagickFalse);
return(y);
}
-static MagickBooleanType DitherImage(Image *image,CubeInfo *cube_info)
+static MagickBooleanType DitherImage(Image *image,CubeInfo *cube_info,
+ ExceptionInfo *exception)
{
CacheView
*image_view;
depth;
if (cube_info->quantize_info->dither_method != RiemersmaDitherMethod)
- return(FloydSteinbergDither(image,cube_info));
+ return(FloydSteinbergDither(image,cube_info,exception));
/*
Distribute quantization error along a Hilbert curve.
*/
cube_info->span=(MagickSizeType) image->columns*image->rows;
image_view=AcquireCacheView(image);
if (depth > 1)
- Riemersma(image,image_view,cube_info,depth-1,NorthGravity);
- status=RiemersmaDither(image,image_view,cube_info,ForgetGravity);
+ Riemersma(image,image_view,cube_info,depth-1,NorthGravity,exception);
+ status=RiemersmaDither(image,image_view,cube_info,ForgetGravity,exception);
image_view=DestroyCacheView(image_view);
return(status);
}
%
% The format of the GetImageQuantizeError method is:
%
-% MagickBooleanType GetImageQuantizeError(Image *image)
+% MagickBooleanType GetImageQuantizeError(Image *image,
+% ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o image: the image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
-MagickExport MagickBooleanType GetImageQuantizeError(Image *image)
+MagickExport MagickBooleanType GetImageQuantizeError(Image *image,
+ ExceptionInfo *exception)
{
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickRealType
alpha,
area,
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- image->total_colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
+ image->total_colors=GetNumberColors(image,(FILE *) NULL,exception);
(void) ResetMagickMemory(&image->error,0,sizeof(image->error));
if (image->storage_class == DirectClass)
return(MagickTrue);
maximum_error=0.0;
mean_error_per_pixel=0.0;
mean_error=0.0;
- exception=(&image->exception);
image_view=AcquireCacheView(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
if (maximum_colors > MaxColormapSize)
maximum_colors=MaxColormapSize;
if ((image->columns*image->rows) <= maximum_colors)
- (void) DirectToColormapImage(image,&image->exception);
- if ((IsImageGray(image,&image->exception) != MagickFalse) &&
+ (void) DirectToColormapImage(image,exception);
+ if ((IsImageGray(image,exception) != MagickFalse) &&
(image->matte == MagickFalse))
(void) SetGrayscaleImage(image,exception);
if ((image->storage_class == PseudoClass) &&
if (cube_info == (CubeInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
- status=ClassifyImageColors(cube_info,image,&image->exception);
+ status=ClassifyImageColors(cube_info,image,exception);
if (status != MagickFalse)
{
/*
cube_info=GetCubeInfo(quantize_info,depth,maximum_colors);
if (cube_info == (CubeInfo *) NULL)
{
- (void) ThrowMagickException(&images->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",images->filename);
return(MagickFalse);
}
{
progress_monitor=SetImageProgressMonitor(image,(MagickProgressMonitor) NULL,
image->client_data);
- status=ClassifyImageColors(cube_info,image,&image->exception);
+ status=ClassifyImageColors(cube_info,image,exception);
if (status == MagickFalse)
break;
(void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
if (cube_info == (CubeInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
- status=ClassifyImageColors(cube_info,remap_image,&image->exception);
+ status=ClassifyImageColors(cube_info,remap_image,exception);
if (status != MagickFalse)
{
/*
image_view=DestroyCacheView(image_view);
colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);
image->type=GrayscaleType;
- if (IsImageMonochrome(image,&image->exception) != MagickFalse)
+ if (IsImageMonochrome(image,exception) != MagickFalse)
image->type=BilevelType;
return(status);
}