Skip to content

Commit

Permalink
enable error diffusion for -posterize (ImageMagick/ImageMagick#7079)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Feb 1, 2024
1 parent f4373e6 commit fe69d65
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions magick/quantize.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ static MagickBooleanType AssignImageColors(Image *image,QCubeInfo *cube_info)
ColorspaceType
colorspace;

ssize_t
y;

size_t
number_colors;

ssize_t
y;

/*
Allocate image colormap.
*/
Expand Down Expand Up @@ -1072,12 +1072,12 @@ MagickExport QuantizeInfo *CloneQuantizeInfo(const QuantizeInfo *quantize_info)
static void ClosestColor(const Image *image,QCubeInfo *cube_info,
const QNodeInfo *node_info)
{
ssize_t
i;

size_t
number_children;

ssize_t
i;

/*
Traverse any children.
*/
Expand Down Expand Up @@ -2329,9 +2329,8 @@ MagickExport MagickBooleanType PosterizeImageChannel(Image *image,
const ChannelType channel,const size_t levels,const MagickBooleanType dither)
{
#define PosterizeImageTag "Posterize/Image"
#define PosterizePixel(pixel) ClampToQuantum((MagickRealType) QuantumRange*( \
MagickRound(QuantumScale*(MagickRealType) pixel*(levels-1)))/ \
MagickMax((ssize_t) levels-1,1))
#define PosterizePixel(pixel) ClampToQuantum(((MagickRealType) \
QuantumScale*(pixel)*levels)*((MagickRealType) QuantumRange/levels))

CacheView
*image_view;
Expand Down Expand Up @@ -2445,9 +2444,8 @@ MagickExport MagickBooleanType PosterizeImageChannel(Image *image,
image_view=DestroyCacheView(image_view);
quantize_info=AcquireQuantizeInfo((ImageInfo *) NULL);
quantize_info->number_colors=(size_t) MagickMin((ssize_t) levels*levels*
levels,MaxColormapSize+1);
levels,MaxColormapSize);
quantize_info->dither=dither;
quantize_info->tree_depth=MaxTreeDepth;
status=QuantizeImage(quantize_info,image);
quantize_info=DestroyQuantizeInfo(quantize_info);
return(status);
Expand Down

0 comments on commit fe69d65

Please sign in to comment.