Method: Magick::Image#add_noise_channel
- Defined in:
- ext/RMagick/rmimage.cpp
#add_noise_channel(noise_type, channel = Magick::AllChannels) ⇒ Magick::Image #add_noise_channel(noise_type, *channels) ⇒ Magick::Image
Adds random noise to the specified channel or channels in the image.
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'ext/RMagick/rmimage.cpp', line 734
VALUE
Image_add_noise_channel(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
NoiseType noise_type;
ExceptionInfo *exception;
ChannelType channels;
image = rm_check_destroyed(self);
channels = extract_channels(&argc, argv);
// There must be 1 remaining argument.
if (argc == 0)
{
rb_raise(rb_eArgError, "missing noise type argument");
}
else if (argc > 1)
{
raise_ChannelType_error(argv[argc-1]);
}
VALUE_TO_ENUM(argv[0], noise_type, NoiseType);
channels = (ChannelType)(channels & ~OpacityChannel);
exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
BEGIN_CHANNEL_MASK(image, channels);
GVL_STRUCT_TYPE(AddNoiseImage) args = { image, noise_type, 1.0, exception };
new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AddNoiseImage), &args);
END_CHANNEL_MASK(new_image);
#else
GVL_STRUCT_TYPE(AddNoiseImageChannel) args = { image, channels, noise_type, exception };
new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AddNoiseImageChannel), &args);
#endif
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
return rm_image_new(new_image);
}
|