Method: Magick::Image#level2
- Defined in:
- ext/RMagick/rmimage.cpp
#level2(black_point = 0.0, white_point = Magick::QuantumRange, gamma = 1.0) ⇒ Magick::Image
Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.
8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 |
# File 'ext/RMagick/rmimage.cpp', line 8492
VALUE
Image_level2(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
double black_point = 0.0, gamma_val = 1.0, white_point = (double)QuantumRange;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#else
char level[50];
#endif
image = rm_check_destroyed(self);
switch (argc)
{
case 0: // take all the defaults
break;
case 1:
black_point = NUM2DBL(argv[0]);
white_point = QuantumRange - black_point;
break;
case 2:
black_point = NUM2DBL(argv[0]);
white_point = NUM2DBL(argv[1]);
break;
case 3:
black_point = NUM2DBL(argv[0]);
white_point = NUM2DBL(argv[1]);
gamma_val = NUM2DBL(argv[2]);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc);
break;
}
new_image = rm_clone_image(image);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(LevelImage) args = { new_image, black_point, white_point, gamma_val, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
snprintf(level, sizeof(level), "%gx%g+%g", black_point, white_point, gamma_val);
GVL_STRUCT_TYPE(LevelImage) args = { new_image, level };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
rm_check_image_exception(new_image, DestroyOnError);
#endif
return rm_image_new(new_image);
}
|