Method: Magick::Image#composite_mathematics

Defined in:
ext/RMagick/rmimage.cpp

#composite_mathematics(image, a, b, c, d, gravity) ⇒ Magick::Image #composite_mathematics(image, a, b, c, d, x_off, y_off) ⇒ Magick::Image #composite_mathematics(image, a, b, c, d, gravity, x_off, y_off) ⇒ Magick::Image

Merge the source and destination images according to the formula

a*Sc*Dc + b*Sc + c*Dc + d

where Sc is the source pixel and Dc is the destination pixel.

Overloads:

  • #composite_mathematics(image, a, b, c, d, gravity) ⇒ Magick::Image

    Parameters:

    • image (Magick::Image, Magick::ImageList)

      Either an imagelist or an image. If an imagelist, uses the current image.

    • a (Numeric)

      See the description.

    • b (Numeric)

      See the description.

    • c (Numeric)

      See the description.

    • d (Numeric)

      See the description.

    • gravity (Magick::GravityType)

      the gravity type

  • #composite_mathematics(image, a, b, c, d, x_off, y_off) ⇒ Magick::Image

    Parameters:

    • image (Magick::Image, Magick::ImageList)

      Either an imagelist or an image. If an imagelist, uses the current image.

    • a (Numeric)

      See the description.

    • b (Numeric)

      See the description.

    • c (Numeric)

      See the description.

    • d (Numeric)

      See the description.

    • x_off (Numeric)

      The x-offset of the composited image, measured relative to the gravity argument.

    • y_off (Numeric)

      The y-offset of the composited image, measured relative to the gravity argument.

  • #composite_mathematics(image, a, b, c, d, gravity, x_off, y_off) ⇒ Magick::Image

    Parameters:

    • image (Magick::Image, Magick::ImageList)

      Either an imagelist or an image. If an imagelist, uses the current image.

    • a (Numeric)

      See the description.

    • b (Numeric)

      See the description.

    • c (Numeric)

      See the description.

    • d (Numeric)

      See the description.

    • gravity (Magick::GravityType)

      the gravity type

    • x_off (Numeric)

      The x-offset of the composited image, measured relative to the gravity argument.

    • y_off (Numeric)

      The y-offset of the composited image, measured relative to the gravity argument.

Returns:



4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
# File 'ext/RMagick/rmimage.cpp', line 4058

VALUE
Image_composite_mathematics(int argc, VALUE *argv, VALUE self)
{
    Image *composite_image;
    VALUE args[5];
    signed long x_off = 0L;
    signed long y_off = 0L;
    GravityType gravity = NorthWestGravity;
    char compose_args[200];

    rm_check_destroyed(self);

    switch (argc)
    {
        case 8:
            VALUE_TO_ENUM(argv[5], gravity, GravityType);
            x_off = NUM2LONG(argv[6]);
            y_off = NUM2LONG(argv[7]);
            break;
        case 7:
            x_off = NUM2LONG(argv[5]);
            y_off = NUM2LONG(argv[6]);
            break;
        case 6:
            VALUE_TO_ENUM(argv[5], gravity, GravityType);
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 6 to 8)", argc);
            break;
    }

    composite_image = rm_check_destroyed(rm_cur_image(argv[0]));

    snprintf(compose_args, sizeof(compose_args), "%-.16g,%-.16g,%-.16g,%-.16g", NUM2DBL(argv[1]), NUM2DBL(argv[2]), NUM2DBL(argv[3]), NUM2DBL(argv[4]));
    SetImageArtifact(composite_image, "compose:args", compose_args);

    // Call composite(False, gravity, x_off, y_off, MathematicsCompositeOp, DefaultChannels)
    args[0] = argv[0];
    args[1] = GravityType_find(gravity);
    args[2] = LONG2FIX(x_off);
    args[3] = LONG2FIX(y_off);
    args[4] = CompositeOperator_find(MathematicsCompositeOp);

    return composite(False, 5, args, self, DefaultChannels);
}