magick/cache-view.h magick/cipher.c magick/cipher.h \
magick/client.c magick/client.h magick/coder.c magick/coder.h \
magick/color.c magick/color.h magick/color-private.h \
+ magick/colormap.c magick/colormap.h magick/colormap-private.h \
magick/colorspace.c magick/colorspace.h \
magick/colorspace-private.h magick/compare.c magick/compare.h \
magick/composite.c magick/composite.h \
magick/magick_libMagickCore_la-client.lo \
magick/magick_libMagickCore_la-coder.lo \
magick/magick_libMagickCore_la-color.lo \
+ magick/magick_libMagickCore_la-colormap.lo \
magick/magick_libMagickCore_la-colorspace.lo \
magick/magick_libMagickCore_la-compare.lo \
magick/magick_libMagickCore_la-composite.lo \
magick/color.c \
magick/color.h \
magick/color-private.h \
+ magick/colormap.c \
+ magick/colormap.h \
+ magick/colormap-private.h \
magick/colorspace.c \
magick/colorspace.h \
magick/colorspace-private.h \
magick/client.h \
magick/coder.h \
magick/color.h \
+ magick/colormap.h \
magick/colorspace.h \
magick/compare.h \
magick/composite.h \
magick/blob-private.h \
magick/cache-private.h \
magick/color-private.h \
+ magick/colormap-private.h \
magick/colorspace-private.h \
magick/composite-private.h \
magick/delegate-private.h \
magick/$(DEPDIR)/$(am__dirstamp)
magick/magick_libMagickCore_la-color.lo: magick/$(am__dirstamp) \
magick/$(DEPDIR)/$(am__dirstamp)
+magick/magick_libMagickCore_la-colormap.lo: magick/$(am__dirstamp) \
+ magick/$(DEPDIR)/$(am__dirstamp)
magick/magick_libMagickCore_la-colorspace.lo: magick/$(am__dirstamp) \
magick/$(DEPDIR)/$(am__dirstamp)
magick/magick_libMagickCore_la-compare.lo: magick/$(am__dirstamp) \
-rm -f magick/magick_libMagickCore_la-coder.lo
-rm -f magick/magick_libMagickCore_la-color.$(OBJEXT)
-rm -f magick/magick_libMagickCore_la-color.lo
+ -rm -f magick/magick_libMagickCore_la-colormap.$(OBJEXT)
+ -rm -f magick/magick_libMagickCore_la-colormap.lo
-rm -f magick/magick_libMagickCore_la-colorspace.$(OBJEXT)
-rm -f magick/magick_libMagickCore_la-colorspace.lo
-rm -f magick/magick_libMagickCore_la-compare.$(OBJEXT)
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-client.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-coder.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-color.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-colormap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-colorspace.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-compare.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@magick/$(DEPDIR)/magick_libMagickCore_la-composite.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(magick_libMagickCore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o magick/magick_libMagickCore_la-color.lo `test -f 'magick/color.c' || echo '$(srcdir)/'`magick/color.c
+magick/magick_libMagickCore_la-colormap.lo: magick/colormap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(magick_libMagickCore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT magick/magick_libMagickCore_la-colormap.lo -MD -MP -MF magick/$(DEPDIR)/magick_libMagickCore_la-colormap.Tpo -c -o magick/magick_libMagickCore_la-colormap.lo `test -f 'magick/colormap.c' || echo '$(srcdir)/'`magick/colormap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) magick/$(DEPDIR)/magick_libMagickCore_la-colormap.Tpo magick/$(DEPDIR)/magick_libMagickCore_la-colormap.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='magick/colormap.c' object='magick/magick_libMagickCore_la-colormap.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(magick_libMagickCore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o magick/magick_libMagickCore_la-colormap.lo `test -f 'magick/colormap.c' || echo '$(srcdir)/'`magick/colormap.c
+
magick/magick_libMagickCore_la-colorspace.lo: magick/colorspace.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(magick_libMagickCore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT magick/magick_libMagickCore_la-colorspace.lo -MD -MP -MF magick/$(DEPDIR)/magick_libMagickCore_la-colorspace.Tpo -c -o magick/magick_libMagickCore_la-colorspace.lo `test -f 'magick/colorspace.c' || echo '$(srcdir)/'`magick/colorspace.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) magick/$(DEPDIR)/magick_libMagickCore_la-colorspace.Tpo magick/$(DEPDIR)/magick_libMagickCore_la-colorspace.Plo
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color-private.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/delegate.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/exception.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/constitute.h"
#include "magick/enhance.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/draw.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/exception.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/exception.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/cache.h"
#include "magick/cache-view.h"
#include "magick/color.h"
+#include "magick/colormap.h"
#include "magick/color-private.h"
#include "magick/composite.h"
#include "magick/constitute.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
+#include "magick/colormap-private.h"
#include "magick/color-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color-private.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/composite.h"
#include "magick/constitute.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color-private.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/color-private.h"
+#include "magick/colormap-private.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color-private.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
<configure name="NAME" value="ImageMagick"/>
<configure name="LIB_VERSION" value="0x656"/>
<configure name="LIB_VERSION_NUMBER" value="6,5,6,2"/>
- <configure name="RELEASE_DATE" value="2009-09-15"/>
+ <configure name="RELEASE_DATE" value="2009-09-17"/>
<configure name="CONFIGURE" value="./configure "/>
<configure name="PREFIX" value="/usr/local"/>
<configure name="EXEC-PREFIX" value="/usr/local"/>
#include "magick/coder.h"
#include "magick/color.h"
#include "magick/colorspace.h"
+#include "magick/colormap.h"
#include "magick/compare.h"
#include "magick/composite.h"
#include "magick/compress.h"
$call Make client.c
$call Make coder.c
$call Make color.c
+$call Make colormap.c
$call Make colorspace.c
$call Make compare.c
$call Make composite.c
$ deass wand
$library/create libMagick.olb -
animate, annotate, artifact, blob, cache, cache-view, cipher, client, coder, -
- color, colorspace, compare, composite, compress, configure, -
+ color, colormap, colorspace, compare, composite, compress, configure, -
constitute, decorate, delegate, deprecate, display, distort, draw, -
effect, enhance, exception, fx, gem, geometry, hashmap, histogram, identify, -
image, layer, list, locale, log, magic, magick, matrix, memory, mime, -
magick/color.c \
magick/color.h \
magick/color-private.h \
+ magick/colormap.c \
+ magick/colormap.h \
+ magick/colormap-private.h \
magick/colorspace.c \
magick/colorspace.h \
magick/colorspace-private.h \
magick/client.h \
magick/coder.h \
magick/color.h \
+ magick/colormap.h \
magick/colorspace.h \
magick/compare.h \
magick/composite.h \
magick/blob-private.h \
magick/cache-private.h \
magick/color-private.h \
+ magick/colormap-private.h \
magick/colorspace-private.h \
magick/composite-private.h \
magick/delegate-private.h \
return(MagickFalse);
}
-static inline IndexPacket ConstrainColormapIndex(Image *image,
- const unsigned long index)
-{
- if (index < image->colors)
- return((IndexPacket) index);
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
- return((IndexPacket) 0);
-}
-
static inline MagickBooleanType IsGray(const PixelPacket *pixel)
{
if ((pixel->red == pixel->green) && (pixel->green == pixel->blue))
--- /dev/null
+/*
+ Copyright 1999-2009 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.
+ obtain a copy of the License at
+
+ http://www.imagemagick.org/script/license.php
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ MagickCore image colormap methods.
+*/
+#ifndef _MAGICKCORE_COLORMAP_PRIVATE_H
+#define _MAGICKCORE_COLORMAP_PRIVATE_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+#include <magick/image.h>
+#include <magick/color.h>
+#include <magick/exception-private.h>
+
+static inline IndexPacket ConstrainColormapIndex(Image *image,
+ const unsigned long index)
+{
+ if (index < image->colors)
+ return((IndexPacket) index);
+ (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
+ return((IndexPacket) 0);
+}
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif
--- /dev/null
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% CCCC OOO L OOO RRRR M M AAA PPPP %
+% C O O L O O R R MM MM A A P P %
+% C O O L O O RRRR M M M AAAAA PPPP %
+% C O O L O O R R M M A A P %
+% CCCC OOO LLLLL OOO R R M M A A P %
+% %
+% %
+% MagickCore Colormap Methods %
+% %
+% Software Design %
+% John Cristy %
+% July 1992 %
+% %
+% %
+% Copyright 1999-2009 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 %
+% obtain a copy of the License at %
+% %
+% http://www.imagemagick.org/script/license.php %
+% %
+% Unless required by applicable law or agreed to in writing, software %
+% distributed under the License is distributed on an "AS IS" BASIS, %
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
+% See the License for the specific language governing permissions and %
+% limitations under the License. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% We use linked-lists because splay-trees do not currently support duplicate
+% key / value pairs (.e.g X11 green compliance and SVG green compliance).
+%
+*/
+\f
+/*
+ Include declarations.
+*/
+#include "magick/studio.h"
+#include "magick/blob.h"
+#include "magick/cache-view.h"
+#include "magick/cache.h"
+#include "magick/color.h"
+#include "magick/color-private.h"
+#include "magick/colormap.h"
+#include "magick/client.h"
+#include "magick/configure.h"
+#include "magick/exception.h"
+#include "magick/exception-private.h"
+#include "magick/gem.h"
+#include "magick/geometry.h"
+#include "magick/image-private.h"
+#include "magick/memory_.h"
+#include "magick/monitor.h"
+#include "magick/monitor-private.h"
+#include "magick/option.h"
+#include "magick/pixel-private.h"
+#include "magick/quantize.h"
+#include "magick/quantum.h"
+#include "magick/semaphore.h"
+#include "magick/string_.h"
+#include "magick/token.h"
+#include "magick/utility.h"
+#include "magick/xml-tree.h"
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% C y c l e C o l o r m a p I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% CycleColormap() displaces an image's colormap by a given number of
+% positions. If you cycle the colormap a number of times you can produce
+% a psychodelic effect.
+%
+% The format of the CycleColormapImage method is:
+%
+% MagickBooleanType CycleColormapImage(Image *image,const long displace)
+%
+% A description of each parameter follows:
+%
+% o image: the image.
+%
+% o displace: displace the colormap this amount.
+%
+*/
+MagickExport MagickBooleanType CycleColormapImage(Image *image,
+ const long displace)
+{
+ CacheView
+ *image_view;
+
+ ExceptionInfo
+ *exception;
+
+ long
+ y;
+
+ MagickBooleanType
+ status;
+
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
+ if (image->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ if (image->storage_class == DirectClass)
+ (void) SetImageType(image,PaletteType);
+ status=MagickTrue;
+ exception=(&image->exception);
+ image_view=AcquireCacheView(image);
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+ #pragma omp parallel for schedule(static,1) shared(status)
+#endif
+ for (y=0; y < (long) image->rows; y++)
+ {
+ long
+ index;
+
+ register IndexPacket
+ *__restrict indexes;
+
+ register long
+ x;
+
+ register PixelPacket
+ *__restrict q;
+
+ if (status == MagickFalse)
+ continue;
+ q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ if (q == (PixelPacket *) NULL)
+ {
+ status=MagickFalse;
+ continue;
+ }
+ indexes=GetCacheViewAuthenticIndexQueue(image_view);
+ for (x=0; x < (long) image->columns; x++)
+ {
+ index=(long) (indexes[x]+displace) % image->colors;
+ if (index < 0)
+ index+=image->colors;
+ indexes[x]=(IndexPacket) index;
+ q->red=image->colormap[index].red;
+ q->green=image->colormap[index].green;
+ q->blue=image->colormap[index].blue;
+ q++;
+ }
+ if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ status=MagickFalse;
+ }
+ image_view=DestroyCacheView(image_view);
+ return(status);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
++ S o r t C o l o r m a p B y I n t e n s i t y %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% SortColormapByIntensity() sorts the colormap of a PseudoClass image by
+% decreasing color intensity.
+%
+% The format of the SortColormapByIntensity method is:
+%
+% MagickBooleanType SortColormapByIntensity(Image *image)
+%
+% A description of each parameter follows:
+%
+% o image: A pointer to an Image structure.
+%
+*/
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+static int IntensityCompare(const void *x,const void *y)
+{
+ const PixelPacket
+ *color_1,
+ *color_2;
+
+ int
+ intensity;
+
+ color_1=(const PixelPacket *) x;
+ color_2=(const PixelPacket *) y;
+ intensity=(int) PixelIntensityToQuantum(color_2)-
+ (int) PixelIntensityToQuantum(color_1);
+ return(intensity);
+}
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+MagickExport MagickBooleanType SortColormapByIntensity(Image *image)
+{
+ CacheView
+ *image_view;
+
+ ExceptionInfo
+ *exception;
+
+ long
+ y;
+
+ MagickBooleanType
+ status;
+
+ register long
+ i;
+
+ unsigned short
+ *pixels;
+
+ assert(image != (Image *) NULL);
+ if (image->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
+ assert(image->signature == MagickSignature);
+ if (image->storage_class != PseudoClass)
+ return(MagickTrue);
+ /*
+ Allocate memory for pixel indexes.
+ */
+ pixels=(unsigned short *) AcquireQuantumMemory((size_t) image->colors,
+ sizeof(*pixels));
+ if (pixels == (unsigned short *) NULL)
+ ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+ image->filename);
+ /*
+ Assign index values to colormap entries.
+ */
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+ #pragma omp parallel for schedule(static,1) shared(status)
+#endif
+ for (i=0; i < (long) image->colors; i++)
+ image->colormap[i].opacity=(IndexPacket) i;
+ /*
+ Sort image colormap by decreasing color popularity.
+ */
+ qsort((void *) image->colormap,(size_t) image->colors,
+ sizeof(*image->colormap),IntensityCompare);
+ /*
+ Update image colormap indexes to sorted colormap order.
+ */
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+ #pragma omp parallel for schedule(static,1) shared(status)
+#endif
+ for (i=0; i < (long) image->colors; i++)
+ pixels[(long) image->colormap[i].opacity]=(unsigned short) i;
+ status=MagickTrue;
+ exception=(&image->exception);
+ image_view=AcquireCacheView(image);
+ for (y=0; y < (long) image->rows; y++)
+ {
+ IndexPacket
+ index;
+
+ register long
+ x;
+
+ register IndexPacket
+ *__restrict indexes;
+
+ register PixelPacket
+ *__restrict q;
+
+ q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ if (q == (PixelPacket *) NULL)
+ {
+ status=MagickFalse;
+ continue;
+ }
+ indexes=GetCacheViewAuthenticIndexQueue(image_view);
+ for (x=0; x < (long) image->columns; x++)
+ {
+ index=(IndexPacket) pixels[(long) indexes[x]];
+ indexes[x]=index;
+ *q++=image->colormap[(long) index];
+ }
+ if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ status=MagickFalse;
+ if (status == MagickFalse)
+ break;
+ }
+ image_view=DestroyCacheView(image_view);
+ pixels=(unsigned short *) RelinquishMagickMemory(pixels);
+ return(status);
+}
--- /dev/null
+/*
+ Copyright 1999-2009 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.
+ obtain a copy of the License at
+
+ http://www.imagemagick.org/script/license.php
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ MagickCore image colormap methods.
+*/
+#ifndef _MAGICKCORE_COLORMAP_H
+#define _MAGICKCORE_COLORMAP_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+extern MagickExport MagickBooleanType
+ CycleColormapImage(Image *,const long),
+ SortColormapByIntensity(Image *);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif
destination_image=DestroyImage(destination_image);
return(status);
}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% T e x t u r e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% TextureImage() repeatedly tiles the texture image across and down the image
+% canvas.
+%
+% The format of the TextureImage method is:
+%
+% MagickBooleanType TextureImage(Image *image,const Image *texture)
+%
+% A description of each parameter follows:
+%
+% o image: the image.
+%
+% o texture: This image is the texture to layer on the background.
+%
+*/
+MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture)
+{
+#define TextureImageTag "Texture/Image"
+
+ ExceptionInfo
+ *exception;
+
+ long
+ y;
+
+ MagickStatusType
+ status;
+
+ assert(image != (Image *) NULL);
+ if (image->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
+ assert(image->signature == MagickSignature);
+ if (texture == (const Image *) NULL)
+ return(MagickFalse);
+ if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ return(MagickFalse);
+ /*
+ Tile texture onto the image background.
+ */
+ status=MagickTrue;
+ exception=(&image->exception);
+ for (y=0; y < (long) image->rows; y+=texture->rows)
+ {
+ register long
+ x;
+
+ for (x=0; x < (long) image->columns; x+=texture->columns)
+ status|=CompositeImage(image,image->compose,texture,x+
+ texture->tile_offset.x,y+texture->tile_offset.y);
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
+ {
+ MagickBooleanType
+ proceed;
+
+ proceed=SetImageProgress(image,TextureImageTag,y,image->rows);
+ if (proceed == MagickFalse)
+ status=MagickFalse;
+ }
+ }
+ (void) SetImageProgress(image,TextureImageTag,image->rows,image->rows);
+ return(status != 0 ? MagickTrue : MagickFalse);
+}
CompositeImage(Image *,const CompositeOperator,const Image *,const long,
const long),
CompositeImageChannel(Image *,const ChannelType,const CompositeOperator,
- const Image *,const long,const long);
+ const Image *,const long,const long),
+ TextureImage(Image *,const Image *);
#if defined(__cplusplus) || defined(c_plusplus)
}
#include "magick/client.h"
#include "magick/color.h"
#include "magick/color-private.h"
+#include "magick/colormap.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/composite.h"
#include "magick/composite-private.h"
#include "magick/client.h"
#include "magick/color.h"
#include "magick/color-private.h"
+#include "magick/colormap.h"
#include "magick/colorspace.h"
#include "magick/colorspace-private.h"
#include "magick/composite.h"
% %
% %
% %
-% A v e r a g e I m a g e s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% AverageImages() takes a set of images and averages them together. Each
-% image in the set must have the same width and height. AverageImages()
-% returns a single image with each corresponding pixel component of each
-% image averaged. On failure, a NULL image is returned and exception
-% describes the reason for the failure.
-%
-% The format of the AverageImages method is:
-%
-% Image *AverageImages(Image *image,ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o image: the image sequence.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-
-static MagickPixelPacket **DestroyPixelThreadSet(MagickPixelPacket **pixels)
-{
- register long
- i;
-
- assert(pixels != (MagickPixelPacket **) NULL);
- for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
- if (pixels[i] != (MagickPixelPacket *) NULL)
- pixels[i]=(MagickPixelPacket *) RelinquishMagickMemory(pixels[i]);
- pixels=(MagickPixelPacket **) RelinquishAlignedMemory(pixels);
- return(pixels);
-}
-
-static MagickPixelPacket **AcquirePixelThreadSet(const Image *image)
-{
- register long
- i,
- j;
-
- MagickPixelPacket
- **pixels;
-
- unsigned long
- number_threads;
-
- number_threads=GetOpenMPMaximumThreads();
- pixels=(MagickPixelPacket **) AcquireAlignedMemory(number_threads,
- sizeof(*pixels));
- if (pixels == (MagickPixelPacket **) NULL)
- return((MagickPixelPacket **) NULL);
- (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));
- for (i=0; i < (long) number_threads; i++)
- {
- pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(image->columns,
- sizeof(**pixels));
- if (pixels[i] == (MagickPixelPacket *) NULL)
- return(DestroyPixelThreadSet(pixels));
- for (j=0; j < (long) image->columns; j++)
- GetMagickPixelPacket(image,&pixels[i][j]);
- }
- return(pixels);
-}
-
-MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
-{
-#define AverageImageTag "Average/Image"
-
- CacheView
- *average_view;
-
- const Image
- *next;
-
- Image
- *average_image;
-
- long
- progress,
- y;
-
- MagickBooleanType
- status;
-
- MagickPixelPacket
- **average_pixels,
- zero;
-
- unsigned long
- number_images;
-
- /*
- Ensure the image are the same size.
- */
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
- if ((next->columns != image->columns) || (next->rows != image->rows))
- ThrowImageException(OptionError,"ImageWidthsOrHeightsDiffer");
- /*
- Initialize average next attributes.
- */
- average_image=CloneImage(image,image->columns,image->rows,MagickTrue,
- exception);
- if (average_image == (Image *) NULL)
- return((Image *) NULL);
- if (SetImageStorageClass(average_image,DirectClass) == MagickFalse)
- {
- InheritException(exception,&average_image->exception);
- average_image=DestroyImage(average_image);
- return((Image *) NULL);
- }
- average_pixels=AcquirePixelThreadSet(image);
- if (average_pixels == (MagickPixelPacket **) NULL)
- {
- average_image=DestroyImage(average_image);
- ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
- }
- /*
- Average image pixels.
- */
- status=MagickTrue;
- progress=0;
- GetMagickPixelPacket(image,&zero);
- number_images=GetImageListLength(image);
- average_view=AcquireCacheView(average_image);
-#if defined(_OPENMP) && (_OPENMP >= 200203)
- #pragma omp parallel for schedule(static,1) shared(progress,status)
-#endif
- for (y=0; y < (long) average_image->rows; y++)
- {
- CacheView
- *image_view;
-
- const Image
- *next;
-
- MagickPixelPacket
- pixel;
-
- register IndexPacket
- *__restrict average_indexes;
-
- register long
- i,
- id,
- x;
-
- register MagickPixelPacket
- *average_pixel;
-
- register PixelPacket
- *__restrict q;
-
- if (status == MagickFalse)
- continue;
- q=QueueCacheViewAuthenticPixels(average_view,0,y,average_image->columns,1,
- exception);
- if (q == (PixelPacket *) NULL)
- {
- status=MagickFalse;
- continue;
- }
- average_indexes=GetCacheViewAuthenticIndexQueue(average_view);
- pixel=zero;
- id=GetOpenMPThreadId();
- average_pixel=average_pixels[id];
- for (x=0; x < (long) average_image->columns; x++)
- average_pixel[x]=zero;
- next=image;
- for (i=0; i < (long) number_images; i++)
- {
- register const IndexPacket
- *indexes;
-
- register const PixelPacket
- *p;
-
- image_view=AcquireCacheView(next);
- p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
- if (p == (const PixelPacket *) NULL)
- {
- image_view=DestroyCacheView(image_view);
- break;
- }
- indexes=GetCacheViewVirtualIndexQueue(image_view);
- for (x=0; x < (long) next->columns; x++)
- {
- SetMagickPixelPacket(next,p,indexes+x,&pixel);
- average_pixel[x].red+=QuantumScale*pixel.red;
- average_pixel[x].green+=QuantumScale*pixel.green;
- average_pixel[x].blue+=QuantumScale*pixel.blue;
- average_pixel[x].opacity+=QuantumScale*pixel.opacity;
- if (average_image->colorspace == CMYKColorspace)
- average_pixel[x].index+=QuantumScale*pixel.index;
- p++;
- }
- image_view=DestroyCacheView(image_view);
- next=GetNextImageInList(next);
- }
- for (x=0; x < (long) average_image->columns; x++)
- {
- average_pixel[x].red=(MagickRealType) (QuantumRange*
- average_pixel[x].red/number_images);
- average_pixel[x].green=(MagickRealType) (QuantumRange*
- average_pixel[x].green/number_images);
- average_pixel[x].blue=(MagickRealType) (QuantumRange*
- average_pixel[x].blue/number_images);
- average_pixel[x].opacity=(MagickRealType) (QuantumRange*
- average_pixel[x].opacity/number_images);
- if (average_image->colorspace == CMYKColorspace)
- average_pixel[x].index=(MagickRealType) (QuantumRange*
- average_pixel[x].index/number_images);
- SetPixelPacket(average_image,&average_pixel[x],q,average_indexes+x);
- q++;
- }
- if (SyncCacheViewAuthenticPixels(average_view,exception) == MagickFalse)
- status=MagickFalse;
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
-#if defined(_OPENMP) && (_OPENMP >= 200203)
- #pragma omp critical (MagickCore_AverageImages)
-#endif
- proceed=SetImageProgress(image,AverageImageTag,progress++,
- average_image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- average_view=DestroyCacheView(average_view);
- average_pixels=DestroyPixelThreadSet(average_pixels);
- if (status == MagickFalse)
- average_image=DestroyImage(average_image);
- return(average_image);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
% C a t c h I m a g e E x c e p t i o n %
% %
% %
% %
% %
% %
-% C y c l e C o l o r m a p I m a g e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% CycleColormap() displaces an image's colormap by a given number of
-% positions. If you cycle the colormap a number of times you can produce
-% a psychodelic effect.
-%
-% The format of the CycleColormapImage method is:
-%
-% MagickBooleanType CycleColormapImage(Image *image,const long displace)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-% o displace: displace the colormap this amount.
-%
-*/
-MagickExport MagickBooleanType CycleColormapImage(Image *image,
- const long displace)
-{
- CacheView
- *image_view;
-
- ExceptionInfo
- *exception;
-
- long
- y;
-
- MagickBooleanType
- status;
-
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- if (image->storage_class == DirectClass)
- (void) SetImageType(image,PaletteType);
- status=MagickTrue;
- exception=(&image->exception);
- image_view=AcquireCacheView(image);
-#if defined(_OPENMP) && (_OPENMP >= 200203)
- #pragma omp parallel for schedule(static,1) shared(status)
-#endif
- for (y=0; y < (long) image->rows; y++)
- {
- long
- index;
-
- register IndexPacket
- *__restrict indexes;
-
- register long
- x;
-
- register PixelPacket
- *__restrict q;
-
- if (status == MagickFalse)
- continue;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
- {
- status=MagickFalse;
- continue;
- }
- indexes=GetCacheViewAuthenticIndexQueue(image_view);
- for (x=0; x < (long) image->columns; x++)
- {
- index=(long) (indexes[x]+displace) % image->colors;
- if (index < 0)
- index+=image->colors;
- indexes[x]=(IndexPacket) index;
- q->red=image->colormap[index].red;
- q->green=image->colormap[index].green;
- q->blue=image->colormap[index].blue;
- q++;
- }
- if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
- status=MagickFalse;
- }
- image_view=DestroyCacheView(image_view);
- return(status);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
% D e s t r o y I m a g e %
% %
% %
return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
}
\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ S o r t C o l o r m a p B y I n t e n s i t y %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% SortColormapByIntensity() sorts the colormap of a PseudoClass image by
-% decreasing color intensity.
-%
-% The format of the SortColormapByIntensity method is:
-%
-% MagickBooleanType SortColormapByIntensity(Image *image)
-%
-% A description of each parameter follows:
-%
-% o image: A pointer to an Image structure.
-%
-*/
-
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-static int IntensityCompare(const void *x,const void *y)
-{
- const PixelPacket
- *color_1,
- *color_2;
-
- int
- intensity;
-
- color_1=(const PixelPacket *) x;
- color_2=(const PixelPacket *) y;
- intensity=(int) PixelIntensityToQuantum(color_2)-
- (int) PixelIntensityToQuantum(color_1);
- return(intensity);
-}
-
-#if defined(__cplusplus) || defined(c_plusplus)
-}
-#endif
-
-MagickExport MagickBooleanType SortColormapByIntensity(Image *image)
-{
- CacheView
- *image_view;
-
- ExceptionInfo
- *exception;
-
- long
- y;
-
- MagickBooleanType
- status;
-
- register long
- i;
-
- unsigned short
- *pixels;
-
- assert(image != (Image *) NULL);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- assert(image->signature == MagickSignature);
- if (image->storage_class != PseudoClass)
- return(MagickTrue);
- /*
- Allocate memory for pixel indexes.
- */
- pixels=(unsigned short *) AcquireQuantumMemory((size_t) image->colors,
- sizeof(*pixels));
- if (pixels == (unsigned short *) NULL)
- ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
- image->filename);
- /*
- Assign index values to colormap entries.
- */
-#if defined(_OPENMP) && (_OPENMP >= 200203)
- #pragma omp parallel for schedule(static,1) shared(status)
-#endif
- for (i=0; i < (long) image->colors; i++)
- image->colormap[i].opacity=(IndexPacket) i;
- /*
- Sort image colormap by decreasing color popularity.
- */
- qsort((void *) image->colormap,(size_t) image->colors,
- sizeof(*image->colormap),IntensityCompare);
- /*
- Update image colormap indexes to sorted colormap order.
- */
-#if defined(_OPENMP) && (_OPENMP >= 200203)
- #pragma omp parallel for schedule(static,1) shared(status)
-#endif
- for (i=0; i < (long) image->colors; i++)
- pixels[(long) image->colormap[i].opacity]=(unsigned short) i;
- status=MagickTrue;
- exception=(&image->exception);
- image_view=AcquireCacheView(image);
- for (y=0; y < (long) image->rows; y++)
- {
- IndexPacket
- index;
-
- register long
- x;
-
- register IndexPacket
- *__restrict indexes;
-
- register PixelPacket
- *__restrict q;
-
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
- {
- status=MagickFalse;
- continue;
- }
- indexes=GetCacheViewAuthenticIndexQueue(image_view);
- for (x=0; x < (long) image->columns; x++)
- {
- index=(IndexPacket) pixels[(long) indexes[x]];
- indexes[x]=index;
- *q++=image->colormap[(long) index];
- }
- if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
- status=MagickFalse;
- if (status == MagickFalse)
- break;
- }
- image_view=DestroyCacheView(image_view);
- pixels=(unsigned short *) RelinquishMagickMemory(pixels);
- return(status);
-}
-
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
return(status);
}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% T e x t u r e I m a g e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% TextureImage() repeatedly tiles the texture image across and down the image
-% canvas.
-%
-% The format of the TextureImage method is:
-%
-% MagickBooleanType TextureImage(Image *image,const Image *texture)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-% o texture: This image is the texture to layer on the background.
-%
-*/
-MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture)
-{
-#define TextureImageTag "Texture/Image"
-
- ExceptionInfo
- *exception;
-
- long
- y;
-
- MagickStatusType
- status;
-
- assert(image != (Image *) NULL);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- assert(image->signature == MagickSignature);
- if (texture == (const Image *) NULL)
- return(MagickFalse);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
- return(MagickFalse);
- /*
- Tile texture onto the image background.
- */
- status=MagickTrue;
- exception=(&image->exception);
- for (y=0; y < (long) image->rows; y+=texture->rows)
- {
- register long
- x;
-
- for (x=0; x < (long) image->columns; x+=texture->columns)
- status|=CompositeImage(image,image->compose,texture,x+
- texture->tile_offset.x,y+texture->tile_offset.y);
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
- proceed=SetImageProgress(image,TextureImageTag,y,image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- (void) SetImageProgress(image,TextureImageTag,image->rows,image->rows);
- return(status != 0 ? MagickTrue : MagickFalse);
-}
extern MagickExport Image
*AcquireImage(const ImageInfo *),
*AppendImages(const Image *,const MagickBooleanType,ExceptionInfo *),
- *AverageImages(const Image *,ExceptionInfo *),
*CloneImage(const Image *,const unsigned long,const unsigned long,
const MagickBooleanType,ExceptionInfo *),
*CombineImages(const Image *,const ChannelType,ExceptionInfo *),
AcquireImageColormap(Image *,const unsigned long),
ClipImage(Image *),
ClipImagePath(Image *,const char *,const MagickBooleanType),
- CycleColormapImage(Image *,const long),
GetImageAlphaChannel(const Image *),
IsTaintImage(const Image *),
IsMagickConflict(const char *),
SetImageOpacity(Image *,const Quantum),
SetImageStorageClass(Image *,const ClassType),
SetImageType(Image *,const ImageType),
- SortColormapByIntensity(Image *),
StripImage(Image *),
- SyncImage(Image *),
- TextureImage(Image *,const Image *);
+ SyncImage(Image *);
extern MagickExport size_t
InterpretImageFilename(const ImageInfo *,Image *,const char *,int,char *);
% %
% %
% %
+% A v e r a g e I m a g e s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AverageImages() takes a set of images and averages them together. Each
+% image in the set must have the same width and height. AverageImages()
+% returns a single image with each corresponding pixel component of each
+% image averaged. On failure, a NULL image is returned and exception
+% describes the reason for the failure.
+%
+% The format of the AverageImages method is:
+%
+% Image *AverageImages(Image *image,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: the image sequence.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+
+static MagickPixelPacket **DestroyPixelThreadSet(MagickPixelPacket **pixels)
+{
+ register long
+ i;
+
+ assert(pixels != (MagickPixelPacket **) NULL);
+ for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+ if (pixels[i] != (MagickPixelPacket *) NULL)
+ pixels[i]=(MagickPixelPacket *) RelinquishMagickMemory(pixels[i]);
+ pixels=(MagickPixelPacket **) RelinquishAlignedMemory(pixels);
+ return(pixels);
+}
+
+static MagickPixelPacket **AcquirePixelThreadSet(const Image *image)
+{
+ register long
+ i,
+ j;
+
+ MagickPixelPacket
+ **pixels;
+
+ unsigned long
+ number_threads;
+
+ number_threads=GetOpenMPMaximumThreads();
+ pixels=(MagickPixelPacket **) AcquireAlignedMemory(number_threads,
+ sizeof(*pixels));
+ if (pixels == (MagickPixelPacket **) NULL)
+ return((MagickPixelPacket **) NULL);
+ (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));
+ for (i=0; i < (long) number_threads; i++)
+ {
+ pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(image->columns,
+ sizeof(**pixels));
+ if (pixels[i] == (MagickPixelPacket *) NULL)
+ return(DestroyPixelThreadSet(pixels));
+ for (j=0; j < (long) image->columns; j++)
+ GetMagickPixelPacket(image,&pixels[i][j]);
+ }
+ return(pixels);
+}
+
+MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
+{
+#define AverageImageTag "Average/Image"
+
+ CacheView
+ *average_view;
+
+ const Image
+ *next;
+
+ Image
+ *average_image;
+
+ long
+ progress,
+ y;
+
+ MagickBooleanType
+ status;
+
+ MagickPixelPacket
+ **average_pixels,
+ zero;
+
+ unsigned long
+ number_images;
+
+ /*
+ Ensure the image are the same size.
+ */
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
+ if (image->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
+ if ((next->columns != image->columns) || (next->rows != image->rows))
+ ThrowImageException(OptionError,"ImageWidthsOrHeightsDiffer");
+ /*
+ Initialize average next attributes.
+ */
+ average_image=CloneImage(image,image->columns,image->rows,MagickTrue,
+ exception);
+ if (average_image == (Image *) NULL)
+ return((Image *) NULL);
+ if (SetImageStorageClass(average_image,DirectClass) == MagickFalse)
+ {
+ InheritException(exception,&average_image->exception);
+ average_image=DestroyImage(average_image);
+ return((Image *) NULL);
+ }
+ average_pixels=AcquirePixelThreadSet(image);
+ if (average_pixels == (MagickPixelPacket **) NULL)
+ {
+ average_image=DestroyImage(average_image);
+ ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+ }
+ /*
+ Average image pixels.
+ */
+ status=MagickTrue;
+ progress=0;
+ GetMagickPixelPacket(image,&zero);
+ number_images=GetImageListLength(image);
+ average_view=AcquireCacheView(average_image);
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+ #pragma omp parallel for schedule(static,1) shared(progress,status)
+#endif
+ for (y=0; y < (long) average_image->rows; y++)
+ {
+ CacheView
+ *image_view;
+
+ const Image
+ *next;
+
+ MagickPixelPacket
+ pixel;
+
+ register IndexPacket
+ *__restrict average_indexes;
+
+ register long
+ i,
+ id,
+ x;
+
+ register MagickPixelPacket
+ *average_pixel;
+
+ register PixelPacket
+ *__restrict q;
+
+ if (status == MagickFalse)
+ continue;
+ q=QueueCacheViewAuthenticPixels(average_view,0,y,average_image->columns,1,
+ exception);
+ if (q == (PixelPacket *) NULL)
+ {
+ status=MagickFalse;
+ continue;
+ }
+ average_indexes=GetCacheViewAuthenticIndexQueue(average_view);
+ pixel=zero;
+ id=GetOpenMPThreadId();
+ average_pixel=average_pixels[id];
+ for (x=0; x < (long) average_image->columns; x++)
+ average_pixel[x]=zero;
+ next=image;
+ for (i=0; i < (long) number_images; i++)
+ {
+ register const IndexPacket
+ *indexes;
+
+ register const PixelPacket
+ *p;
+
+ image_view=AcquireCacheView(next);
+ p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
+ if (p == (const PixelPacket *) NULL)
+ {
+ image_view=DestroyCacheView(image_view);
+ break;
+ }
+ indexes=GetCacheViewVirtualIndexQueue(image_view);
+ for (x=0; x < (long) next->columns; x++)
+ {
+ SetMagickPixelPacket(next,p,indexes+x,&pixel);
+ average_pixel[x].red+=QuantumScale*pixel.red;
+ average_pixel[x].green+=QuantumScale*pixel.green;
+ average_pixel[x].blue+=QuantumScale*pixel.blue;
+ average_pixel[x].opacity+=QuantumScale*pixel.opacity;
+ if (average_image->colorspace == CMYKColorspace)
+ average_pixel[x].index+=QuantumScale*pixel.index;
+ p++;
+ }
+ image_view=DestroyCacheView(image_view);
+ next=GetNextImageInList(next);
+ }
+ for (x=0; x < (long) average_image->columns; x++)
+ {
+ average_pixel[x].red=(MagickRealType) (QuantumRange*
+ average_pixel[x].red/number_images);
+ average_pixel[x].green=(MagickRealType) (QuantumRange*
+ average_pixel[x].green/number_images);
+ average_pixel[x].blue=(MagickRealType) (QuantumRange*
+ average_pixel[x].blue/number_images);
+ average_pixel[x].opacity=(MagickRealType) (QuantumRange*
+ average_pixel[x].opacity/number_images);
+ if (average_image->colorspace == CMYKColorspace)
+ average_pixel[x].index=(MagickRealType) (QuantumRange*
+ average_pixel[x].index/number_images);
+ SetPixelPacket(average_image,&average_pixel[x],q,average_indexes+x);
+ q++;
+ }
+ if (SyncCacheViewAuthenticPixels(average_view,exception) == MagickFalse)
+ status=MagickFalse;
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
+ {
+ MagickBooleanType
+ proceed;
+
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+ #pragma omp critical (MagickCore_AverageImages)
+#endif
+ proceed=SetImageProgress(image,AverageImageTag,progress++,
+ average_image->rows);
+ if (proceed == MagickFalse)
+ status=MagickFalse;
+ }
+ }
+ average_view=DestroyCacheView(average_view);
+ average_pixels=DestroyPixelThreadSet(average_pixels);
+ if (status == MagickFalse)
+ average_image=DestroyImage(average_image);
+ return(average_image);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+ G e t I m a g e B o u n d i n g B o x %
% %
% %
extern MagickExport ChannelStatistics
*GetImageChannelStatistics(const Image *,ExceptionInfo *);
+extern MagickExport Image
+ *AverageImages(const Image *,ExceptionInfo *);
+
extern MagickExport MagickBooleanType
GetImageChannelExtrema(const Image *,const ChannelType,unsigned long *,
unsigned long *,ExceptionInfo *),
#define MagickLibVersionText "6.5.6"
#define MagickLibVersionNumber 2,0,0
#define MagickLibSubversion "-2"
-#define MagickReleaseDate "2009-09-15"
+#define MagickReleaseDate "2009-09-17"
#define MagickChangeDate "20090913"
#define MagickAuthoritativeURL "http://www.imagemagick.org"
#define MagickHomeURL "file:///usr/local/share/doc/ImageMagick-6.5.6/index.html"