Method: Magick::Image#modulate
- Defined in:
- ext/RMagick/rmimage.cpp
#modulate(brightness = 1.0, saturation = 1.0, hue = 1.0) ⇒ Magick::Image
Changes the brightness, saturation, and hue.
9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 |
# File 'ext/RMagick/rmimage.cpp', line 9570
VALUE
Image_modulate(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
double pct_brightness = 100.0,
pct_saturation = 100.0,
pct_hue = 100.0;
char modulate[100];
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
image = rm_check_destroyed(self);
switch (argc)
{
case 3:
pct_hue = rm_percentage2(argv[2], 1.0, false) * 100.0;
case 2:
pct_saturation = rm_percentage2(argv[1], 1.0, false) * 100.0;
case 1:
pct_brightness = rm_percentage(argv[0], 1.0) * 100.0;
break;
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc);
break;
}
if (pct_brightness <= 0.0)
{
rb_raise(rb_eArgError, "brightness is %g%%, must be positive", pct_brightness);
}
snprintf(modulate, sizeof(modulate), "%f%%,%f%%,%f%%", pct_brightness, pct_saturation, pct_hue);
new_image = rm_clone_image(image);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
rm_check_image_exception(new_image, DestroyOnError);
#endif
return rm_image_new(new_image);
}
|