Method: Magick::Image#spread

Defined in:
ext/RMagick/rmimage.cpp

#spread(radius = 3.0) ⇒ Magick::Image

Randomly displace each pixel in a block defined by “radius”.

Returns a new image.

Parameters:

  • radius (Numeric) (defaults to: 3.0)

    The radius

Returns:



13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
# File 'ext/RMagick/rmimage.cpp', line 13655

VALUE
Image_spread(int argc, VALUE *argv, VALUE self)
{
    Image *image, *new_image;
    double radius = 3.0;
    ExceptionInfo *exception;

    image = rm_check_destroyed(self);
    switch (argc)
    {
        case 1:
            radius = NUM2DBL(argv[0]);
        case 0:
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
            break;
    }

    exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
    GVL_STRUCT_TYPE(SpreadImage) args = { image, image->interpolate, radius, exception };
#else
    GVL_STRUCT_TYPE(SpreadImage) args = { image, radius, exception };
#endif
    new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SpreadImage), &args);
    rm_check_exception(exception, new_image, DestroyOnError);
    DestroyExceptionInfo(exception);

    return rm_image_new(new_image);
}