% MagickCore Image Channel Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% December 2003 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/studio.h"
#include "MagickCore/cache-private.h"
+#include "MagickCore/channel.h"
#include "MagickCore/colorspace-private.h"
#include "MagickCore/composite-private.h"
#include "MagickCore/enhance.h"
channel_op=ExtractChannelOp;
for (channels=0; *token != '\0'; )
{
- MagickBooleanType
- delete_channel;
-
ssize_t
i;
/*
Interpret channel expression.
*/
- delete_channel=MagickFalse;
switch (*token)
{
- case '~':
- {
- delete_channel=MagickTrue;
- GetMagickToken(p,&p,token);
- break;
- }
case ',':
{
- destination_channel=(PixelChannel) ((ssize_t) destination_channel+1);
GetMagickToken(p,&p,token);
break;
}
break;
}
case ExchangeChannelOp:
- {
- PixelChannelMap
- channel_map;
-
- i=ParsePixelChannelOption(token);
- if (i < 0)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
- "UnrecognizedChannelType","`%s'",token);
- destination_image=DestroyImageList(destination_image);
- return(destination_image);
- }
- destination_channel=(PixelChannel) i;
- if ((source_channel >= GetPixelChannels(image)) ||
- (destination_channel >= GetPixelChannels(image)))
- {
- (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
- "NoSuchImageChannel","`%s'",token);
- destination_image=DestroyImageList(destination_image);
- return(destination_image);
- }
- channel_map=destination_image->channel_map[destination_channel];
- destination_image->channel_map[destination_channel]=
- destination_image->channel_map[source_channel];
- destination_image->channel_map[source_channel]=channel_map;
- break;
- }
case TransferChannelOp:
{
i=ParsePixelChannelOption(token);
{
case ExtractChannelOp:
{
- if (delete_channel == MagickFalse)
- channel_mask=(ChannelType) (channel_mask |
- (1 << destination_channel));
- else
- channel_mask=(ChannelType) (channel_mask &~
- (1 << destination_channel));
+ channel_mask=(ChannelType) (channel_mask | (1 << destination_channel));
destination_channel=(PixelChannel) (destination_channel+1);
break;
}
if (GetPixelReadMask(image,p) == 0)
{
+ SetPixelBackgoundColor(separate_image,q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(separate_image);
continue;