if (image->read_mask != MagickFalse || image->write_mask != MagickFalse)
return(MagickFalse);
- /* check if the image has an alpha channel */
- if (image->alpha_trait == UndefinedPixelTrait)
+ if (image->number_channels > 4)
return(MagickFalse);
- /* check if pixel order is RGBA */
- if (GetPixelChannelOffset(image,RedPixelChannel) != 0 ||
- GetPixelChannelOffset(image,GreenPixelChannel) != 1 ||
- GetPixelChannelOffset(image,BluePixelChannel) != 2 ||
- GetPixelChannelOffset(image,AlphaPixelChannel) != 3)
+ /* check if pixel order is R */
+ if ((GetPixelChannelOffset(image,RedPixelChannel) != 0) ||
+ (GetPixelRedTraits(image) == UndefinedPixelTrait))
+ return(MagickFalse);
+
+ if (image->number_channels == 1)
+ return(MagickTrue);
+
+ /* check if pixel order is RA */
+ if ((image->number_channels == 2) &&
+ (GetPixelChannelOffset(image,AlphaPixelChannel) == 1) &&
+ (GetPixelAlphaTraits(image) != UndefinedPixelTrait))
+ return(MagickTrue);
+
+ if (image->number_channels == 2)
return(MagickFalse);
- /* check if all channels are available */
- if ((GetPixelRedTraits(image) == UndefinedPixelTrait) ||
+ /* check if pixel order is RGB */
+ if ((GetPixelChannelOffset(image,GreenPixelChannel) != 1) ||
(GetPixelGreenTraits(image) == UndefinedPixelTrait) ||
- (GetPixelBlueTraits(image) == UndefinedPixelTrait) ||
+ (GetPixelChannelOffset(image,BluePixelChannel) != 2) ||
+ (GetPixelBlueTraits(image) == UndefinedPixelTrait))
+ return(MagickFalse);
+
+ if (image->number_channels == 3)
+ return(MagickTrue);
+
+ /* check if pixel order is RGBA */
+ if ((GetPixelChannelOffset(image,AlphaPixelChannel) != 3) ||
(GetPixelAlphaTraits(image) == UndefinedPixelTrait))
return(MagickFalse);
return(MagickTrue);
}
+static MagickBooleanType checkAccelerateConditionRGBA(const Image* image)
+{
+ if (checkAccelerateCondition(image) == MagickFalse)
+ return(MagickFalse);
+
+ /* the order will be RGBA if the image has 4 channels */
+ if (image->number_channels == 4)
+ return(MagickTrue);
+
+ return(MagickFalse);
+}
+
static MagickBooleanType checkHistogramCondition(Image *image)
{
/* ensure this is the only pass get in for now. */
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkHistogramCondition(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(kernel != (KernelInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return((Image *) NULL);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkHistogramCondition(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(offset != (OffsetInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return(MagickFalse);
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *) NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return NULL;
assert(image != NULL);
assert(exception != (ExceptionInfo *)NULL);
- if ((checkAccelerateCondition(image) == MagickFalse) ||
+ if ((checkAccelerateConditionRGBA(image) == MagickFalse) ||
(checkOpenCLEnvironment(exception) == MagickFalse))
return (Image *) NULL;