void Magick::Image::channel ( const ChannelType channel_ )
{
modifyImage();
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- SeparateImage ( image(), &exceptionInfo );
+ MagickCore::Image* newImage =
+ SeparateImage( image(), channel_, &exceptionInfo);
+ replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
}
// Set or obtain modulus channel depth
/*
- Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
+ Copyright 1999-2011 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.
/*
- Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
+ Copyright 1999-2011 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.
continue;
switch (compose)
{
+ case AlphaCompositeOp:
case ChangeMaskCompositeOp:
case CopyAlphaCompositeOp:
case DstAtopCompositeOp:
composite_traits=GetPixelChannelMapTraits(composite_image,channel);
if (traits == UndefinedPixelTrait)
continue;
- if ((compose != IntensityCompositeOp) &&
+ if ((compose != AlphaCompositeOp) &&
+ (compose != IntensityCompositeOp) &&
(composite_traits == UndefinedPixelTrait))
continue;
/*
*/
switch (compose)
{
+ case AlphaCompositeOp:
+ {
+ pixel=Sa;
+ break;
+ }
case AtopCompositeOp:
case CopyBlackCompositeOp:
case CopyBlueCompositeOp:
typedef enum
{
+ AlphaCompositeOp,
AtopCompositeOp,
BlendCompositeOp,
BlurCompositeOp,
}
else
{
- ChannelType
- channel_mask;
-
Image
*resize_alpha;
distort alpha channel separately
*/
- channel_mask=SetPixelChannelMask(tmp_image,AlphaChannel);
- (void) SeparateImage(tmp_image,exception);
- SetPixelChannelMapMask(tmp_image,channel_mask);
+ (void) SetImageAlphaChannel(tmp_image,ExtractAlphaChannel,exception);
(void) SetImageAlphaChannel(tmp_image,OpaqueAlphaChannel,exception);
resize_alpha=DistortImage(tmp_image,AffineDistortion,12,distort_args,
MagickTrue,exception),
%
% The format of the SeparateImage method is:
%
-% MagickBooleanType SeparateImage(Image *image,ExceptionInfo *exception)
+% Image *SeparateImage(const Image *image,const ChannelType channel,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
+% o channel: the image channel.
+%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport MagickBooleanType SeparateImage(Image *image,
- ExceptionInfo *exception)
+MagickExport Image *SeparateImage(const Image *image,
+ const ChannelType channel_type,ExceptionInfo *exception)
{
+#define GetChannelBit(mask,bit) (((size_t) (mask) >> (size_t) (bit)) & 0x01)
#define SeparateImageTag "Separate/Image"
CacheView
- *image_view;
+ *image_view,
+ *separate_view;
+
+ Image
+ *separate_image;
MagickBooleanType
status;
ssize_t
y;
+ /*
+ Initialize spread image attributes.
+ */
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
- return(MagickFalse);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ separate_image=CloneImage(image,image->columns,image->rows,MagickTrue,
+ exception);
+ if (separate_image == (Image *) NULL)
+ return((Image *) NULL);
+ if (SetImageStorageClass(separate_image,DirectClass,exception) == MagickFalse)
+ {
+ separate_image=DestroyImage(separate_image);
+ return((Image *) NULL);
+ }
+ separate_image->colorspace=GRAYColorspace;
/*
- Separate image channels.
+ Separate image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireCacheView(image);
+ separate_view=AcquireCacheView(separate_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,4) shared(progress,status)
+ #pragma omp parallel for schedule(static,4) shared(progress,status) omp_throttle(1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
+ register const Quantum
+ *restrict p;
+
register Quantum
*restrict q;
if (status == MagickFalse)
continue;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (Quantum *) NULL)
+ p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
+ q=QueueCacheViewAuthenticPixels(separate_view,0,y,separate_image->columns,1,
+ exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
{
status=MagickFalse;
continue;
register ssize_t
i;
+ SetPixelChannel(separate_image,GrayPixelChannel,0,q);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel
PixelTrait
traits;
-
- register ssize_t
- j;
-
+
channel=GetPixelChannelMapChannel(image,i);
traits=GetPixelChannelMapTraits(image,channel);
- if (traits == UndefinedPixelTrait)
+ if ((traits == UndefinedPixelTrait) ||
+ (GetChannelBit(channel_type,channel) == 0))
continue;
- if ((traits & UpdatePixelTrait) != 0)
- for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
- q[j]=q[i];
+ SetPixelChannel(separate_image,GrayPixelChannel,p[i],q);
}
- q+=GetPixelChannels(image);
+ p+=GetPixelChannels(image);
+ q+=GetPixelChannels(separate_image);
}
- if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ if (SyncCacheViewAuthenticPixels(separate_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_SeparateImage)
+ #pragma omp critical (MagickCore_SeparateImage)
#endif
proceed=SetImageProgress(image,SeparateImageTag,progress++,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
+ separate_view=DestroyCacheView(separate_view);
image_view=DestroyCacheView(image_view);
- (void) SetImageColorspace(image,RGBColorspace,exception);
- return(status);
+ return(separate_image);
}
\f
/*
*/
MagickExport Image *SeparateImages(const Image *image,ExceptionInfo *exception)
{
- ChannelType
- channel_mask;
-
Image
*images,
*separate_image;
channel=GetPixelChannelMapChannel(image,i);
traits=GetPixelChannelMapTraits(image,channel);
- if (traits == UndefinedPixelTrait)
+ if ((traits == UndefinedPixelTrait) ||
+ ((traits & UpdatePixelTrait) == 0))
continue;
- if ((traits & UpdatePixelTrait) != 0)
- {
- separate_image=CloneImage(image,0,0,MagickTrue,exception);
- if (separate_image != (Image *) NULL)
- {
- channel_mask=SetPixelChannelMask(separate_image,
- (ChannelType) (1 << i));
- (void) SeparateImage(separate_image,exception);
- (void) SetPixelChannelMapMask(separate_image,channel_mask);
- AppendImageToList(&images,separate_image);
- }
- }
+ separate_image=SeparateImage(image,(ChannelType) (1 << channel),exception);
+ if (separate_image != (Image *) NULL)
+ AppendImageToList(&images,separate_image);
}
return(images);
}
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
const AlphaChannelType alpha_type,ExceptionInfo *exception)
{
- ChannelType
- channel_mask;
-
MagickBooleanType
status;
case CopyAlphaChannel:
{
/*
- Special usage case for SeparateImage(): copy grayscale color to
- the alpha channel.
+ Copy pixel intensity to the alpha channel.
*/
- channel_mask=SetPixelChannelMask(image,GrayChannel);
- status=SeparateImage(image,exception);
- (void) SetPixelChannelMask(image,channel_mask);
- image->matte=MagickTrue; /* make sure transparency is now on! */
+ status=CompositeImage(image,IntensityCompositeOp,image,0,0,exception);
if (alpha_type == ShapeAlphaChannel)
- {
- PixelInfo
- background;
-
- /*
- Reset all color channels to background color.
- */
- background=image->background_color;
- (void) LevelImageColors(image,&background,&background,MagickTrue,
- exception);
- }
+ (void) LevelImageColors(image,&image->background_color,
+ &image->background_color,MagickTrue,exception);
break;
}
case ExtractAlphaChannel:
{
- channel_mask=SetPixelChannelMask(image,AlphaChannel);
- status=SeparateImage(image,exception);
- (void) SetPixelChannelMask(image,channel_mask);
+ status=CompositeImage(image,AlphaCompositeOp,image,0,0,exception);
image->matte=MagickFalse;
break;
}
static inline Quantum PushColormapIndex(Image *image,const Quantum index,
MagickBooleanType *range_exception)
{
- if (index < image->colors)
+ if ((size_t) index < image->colors)
return(index);
*range_exception=MagickTrue;
return(0);
image->type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
option);
option=GetImageOption(image_info,"units");
+ units=image_info->units;
if (option != (const char *) NULL)
units=(ResolutionType) ParseCommandOption(MagickResolutionOptions,
MagickFalse,option);
- else
- units = image_info->units;
if (units != UndefinedResolution)
{
if (image->units != units)
*NewMagickImage(const ImageInfo *,const size_t,const size_t,const PixelInfo *,
ExceptionInfo *),
*ReferenceImage(Image *),
+ *SeparateImage(const Image *,const ChannelType,ExceptionInfo *),
*SeparateImages(const Image *,ExceptionInfo *),
*SmushImages(const Image *,const MagickBooleanType,const ssize_t,
ExceptionInfo *);
ListMagickInfo(FILE *,ExceptionInfo *),
ModifyImage(Image **,ExceptionInfo *),
ResetImagePage(Image *,const char *),
- SeparateImage(Image *,ExceptionInfo *),
SetImageAlpha(Image *,const Quantum,ExceptionInfo *),
SetImageAlphaChannel(Image *,const AlphaChannelType,ExceptionInfo *),
SetImageBackgroundColor(Image *,ExceptionInfo *),
/* #undef AUTOTRACE_DELEGATE */
/* Define if coders and filters are to be built as modules. */
-/* #undef BUILD_MODULES */
+#ifndef MAGICKCORE_BUILD_MODULES
+#define MAGICKCORE_BUILD_MODULES 1
+#endif
/* Define if you have the bzip2 library */
#ifndef MAGICKCORE_BZLIB_DELEGATE
#endif
/* Define to 1 if you have the <CL/cl.h> header file. */
-/* #undef HAVE_CL_CL_H */
+#ifndef MAGICKCORE_HAVE_CL_CL_H
+#define MAGICKCORE_HAVE_CL_CL_H 1
+#endif
/* Define to 1 if you have the <complex.h> header file. */
#ifndef MAGICKCORE_HAVE_COMPLEX_H
#endif
/* Define if you have JBIG library */
-/* #undef JBIG_DELEGATE */
+#ifndef MAGICKCORE_JBIG_DELEGATE
+#define MAGICKCORE_JBIG_DELEGATE 1
+#endif
/* Define if you have JPEG version 2 "Jasper" library */
#ifndef MAGICKCORE_JP2_DELEGATE
/* Define to the system default library search path. */
#ifndef MAGICKCORE_LT_DLSEARCH_PATH
-#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/atlas:/usr/lib/llvm:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib64/tcl8.5:/usr/lib64/tracker-0.12:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2"
+#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/alliance/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/usr/lib64/kicad:/usr/lib/llvm:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mpich2/lib/:/usr/lib64/mysql:/usr/lib64/nvidia:/usr/lib64/openmotif:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib64/tracker-0.12:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2"
#endif
/* The archive extension */
/* #undef NO_MINUS_C_MINUS_O */
/* Define if you have OPENEXR library */
-/* #undef OPENEXR_DELEGATE */
+#ifndef MAGICKCORE_OPENEXR_DELEGATE
+#define MAGICKCORE_OPENEXR_DELEGATE 1
+#endif
/* Name of package */
#ifndef MAGICKCORE_PACKAGE
#endif
/* Define if you have RSVG library */
-/* #undef RSVG_DELEGATE */
+#ifndef MAGICKCORE_RSVG_DELEGATE
+#define MAGICKCORE_RSVG_DELEGATE 1
+#endif
/* Define to the type of arg 1 for `select'. */
#ifndef MAGICKCORE_SELECT_TYPE_ARG1
/* #undef _MINIX */
/* Define this for the OpenCL Accelerator */
-/* #undef _OPENCL */
+#ifndef MAGICKCORE__OPENCL
+#define MAGICKCORE__OPENCL 1
+#endif
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#define ExceptionInfo MagickExceptionInfo
#endif
-typedef enum
-{
- UndefinedChannel = 0x0000,
- RedChannel = 0x0001,
- GrayChannel = 0x0001,
- CyanChannel = 0x0001,
- GreenChannel = 0x0002,
- MagentaChannel = 0x0002,
- BlueChannel = 0x0004,
- YellowChannel = 0x0004,
- BlackChannel = 0x0008,
- AlphaChannel = 0x0010,
- OpacityChannel = 0x0010,
- IndexChannel = 0x0020,
- MaskChannel = 0x0040,
- MetaChannel = 0x0080,
- CompositeChannels = 0x002F,
- AllChannels = 0x7ffffff,
- /*
- Special purpose channel types.
- */
- TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
- RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
- GrayChannels = 0x0400,
- SyncChannels = 0x1000, /* channels should be modified equally */
- DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
-} ChannelType;
-
typedef enum
{
UndefinedClass,
#define MaxPixelChannels 32
#undef index
+typedef enum
+{
+ UndefinedChannel = 0x0000,
+ RedChannel = 0x0001,
+ GrayChannel = 0x0001,
+ CyanChannel = 0x0001,
+ GreenChannel = 0x0002,
+ MagentaChannel = 0x0002,
+ BlueChannel = 0x0004,
+ YellowChannel = 0x0004,
+ BlackChannel = 0x0008,
+ AlphaChannel = 0x0010,
+ OpacityChannel = 0x0010,
+ IndexChannel = 0x0020,
+ MaskChannel = 0x0040,
+ MetaChannel = 0x0080,
+ CompositeChannels = 0x002F,
+ AllChannels = 0x7ffffff,
+ /*
+ Special purpose channel types.
+ */
+ TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
+ RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
+ GrayChannels = 0x0400,
+ SyncChannels = 0x1000, /* channels should be modified equally */
+ DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
+} ChannelType; /* must correspond to PixelChannel */
+
typedef enum
{
UndefinedInterpolatePixel,
IntensityPixelChannel = MaxPixelChannels,
CompositePixelChannel = MaxPixelChannels,
SyncPixelChannel = MaxPixelChannels+1
-} PixelChannel;
+} PixelChannel; /* must correspond to ChannelType */
typedef enum
{
*/
#define MagickPackageName "ImageMagick"
#define MagickCopyright "Copyright (C) 1999-2012 ImageMagick Studio LLC"
-#define MagickSVNRevision "6328"
+#define MagickSVNRevision "exported"
#define MagickLibVersion 0x700
#define MagickLibVersionText "7.0.0"
#define MagickLibVersionNumber 7,0,0
#define MagickLibAddendum "-0"
#define MagickLibInterface 7
#define MagickLibMinInterface 7
-#define MagickReleaseDate "2012-01-06"
+#define MagickReleaseDate "2012-01-11"
#define MagickChangeDate "20110801"
#define MagickAuthoritativeURL "http://www.imagemagick.org"
#if defined(MAGICKCORE_OPENMP_SUPPORT)
%
% The format of the MagickSeparateImage method is:
%
-% MagickBooleanType MagickSeparateImage(MagickWand *wand)
+% MagickBooleanType MagickSeparateImage(MagickWand *wand,
+% const ChannelType channel)
%
% A description of each parameter follows:
%
% o wand: the magick wand.
%
+% o channel: the channel.
+%
*/
-WandExport MagickBooleanType MagickSeparateImage(MagickWand *wand)
+WandExport MagickBooleanType MagickSeparateImage(MagickWand *wand,
+ const ChannelType channel)
{
+ Image
+ *separate_image;
+
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->images == (Image *) NULL)
ThrowWandException(WandError,"ContainsNoImages",wand->name);
- return(SeparateImage(wand->images,wand->exception));
+ separate_image=SeparateImage(wand->images,channel,wand->exception);
+ if (separate_image == (Image *) NULL)
+ return(MagickFalse);
+ ReplaceImageInList(&wand->images,separate_image);
+ return(MagickTrue);
}
\f
/*
const double,const double),
MagickSelectiveBlurImage(MagickWand *,const double,const double,const double,
const double),
- MagickSeparateImage(MagickWand *),
+ MagickSeparateImage(MagickWand *,const ChannelType),
MagickSepiaToneImage(MagickWand *,const double),
MagickSetImage(MagickWand *,const MagickWand *),
MagickSetImageAlphaChannel(MagickWand *,const AlphaChannelType),
{
if (attribute_flag[0] != 0)
channel=(ChannelType) argument_list[0].integer_reference;
- channel_mask=SetPixelChannelMask(image,channel);
- (void) SeparateImage(image,exception);
- (void) SetPixelChannelMask(image,channel_mask);
+ image=SeparateImage(image,channel,exception);
break;
}
case 63: /* Stereo */
{
if (attribute_flag[0] != 0)
channel=(ChannelType) argument_list[0].integer_reference;
- channel_mask=SetPixelChannelMask(image,channel);
- (void) SeparateImage(image,exception);
- (void) SetPixelChannelMask(image,channel_mask);
+ image=SeparateImage(image,channel,exception);
break;
}
case 87: /* Splice */
print("Apple Macintosh QuickDraw/PICT file ...\n");
++$test;
-testReadCompare('input.pict', 'reference/read/input_pict.miff', q//, 0.0, 0.0);
+testReadCompare('input.pict', 'reference/read/input_pict.miff', q//, 0.06, 1.06);
print("Alias/Wavefront RLE image format ...\n");
++$test;
testReadWrite( 'PICT:input.pict',
'PICT:output.pict',
q//,
- '6a4a257921582768b774aeeac549b7c0c0b51f665395eddf921cce53a0ad2a33');
+ '9cadd5855f595a7440821a01e77609f2adde95a228b13fdc906d16069e4daaaa');
print("Portable pixmap format (color), ASCII format ...\n");
++$test;