Class: Magick::KernelInfo
- Inherits:
-
Object
- Object
- Magick::KernelInfo
- Defined in:
- ext/RMagick/rmmain.cpp
Class Method Summary collapse
-
.builtin(what, geometry) ⇒ Magick::KernelInfo
Create new instance of KernelInfo with one of the ‘named’ built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.
Instance Method Summary collapse
-
#clone ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
-
#dup ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
-
#initialize(kernel_string) ⇒ Magick::KernelInfo
constructor
KernelInfo object constructor.
-
#scale(scale, flags) ⇒ Object
Scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).
-
#scale_geometry(geometry) ⇒ Object
Takes a geometry argument string, typically provided as a -set option:convolve:scale {geometry} user setting, and modifies the kernel according to the parsed arguments of that setting.
-
#unity_add(scale) ⇒ Object
Adds a given amount of the ‘Unity’ Convolution Kernel to the given pre-scaled and normalized Kernel.
Constructor Details
#initialize(kernel_string) ⇒ Magick::KernelInfo
KernelInfo object constructor
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'ext/RMagick/rmkinfo.cpp', line 88
VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
KernelInfo *kernel;
char *string = StringValueCStr(kernel_string);
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
exception = AcquireExceptionInfo();
kernel = AcquireKernelInfo(string, exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelInfo(string);
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to parse kernel string");
}
DATA_PTR(self) = kernel;
return self;
}
|
Class Method Details
.builtin(what, geometry) ⇒ Magick::KernelInfo
Create new instance of KernelInfo with one of the ‘named’ built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'ext/RMagick/rmkinfo.cpp', line 221
VALUE
KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
{
KernelInfo *kernel;
KernelInfoType kernel_type;
GeometryInfo info;
const char *geom_str;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
geom_str = StringValueCStr(geometry);
if (ParseGeometry(geom_str, &info) == NoValue && *geom_str)
{
rb_raise(rb_eArgError, "invalid geometry string");
}
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelBuiltIn(kernel_type, &info, exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelBuiltIn(kernel_type, &info);
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
}
return TypedData_Wrap_Struct(self, &rm_kernel_info_data_type, kernel);
}
|
Instance Method Details
#clone ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
201 202 203 204 205 206 207 208 209 210 |
# File 'ext/RMagick/rmkinfo.cpp', line 201
VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo(get_kernel_info(self));
if (!kernel)
{
rb_raise(rb_eNoMemError, "not enough memory to continue");
}
return TypedData_Wrap_Struct(Class_KernelInfo, &rm_kernel_info_data_type, kernel);
}
|
#dup ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
201 202 203 204 205 206 207 208 209 210 |
# File 'ext/RMagick/rmkinfo.cpp', line 201
VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo(get_kernel_info(self));
if (!kernel)
{
rb_raise(rb_eNoMemError, "not enough memory to continue");
}
return TypedData_Wrap_Struct(Class_KernelInfo, &rm_kernel_info_data_type, kernel);
}
|
#scale(scale, flags) ⇒ Object
Scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).
170 171 172 173 174 175 176 177 178 179 180 |
# File 'ext/RMagick/rmkinfo.cpp', line 170
VALUE
KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
{
GeometryFlags geoflags;
VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
GVL_STRUCT_TYPE(ScaleKernelInfo) args = { get_kernel_info(self), NUM2DBL(scale), geoflags };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleKernelInfo), &args);
return Qnil;
}
|
#scale_geometry(geometry) ⇒ Object
Takes a geometry argument string, typically provided as a -set option:convolve:scale {geometry} user setting, and modifies the kernel according to the parsed arguments of that setting.
188 189 190 191 192 193 194 |
# File 'ext/RMagick/rmkinfo.cpp', line 188
VALUE
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
{
GVL_STRUCT_TYPE(ScaleGeometryKernelInfo) args = { get_kernel_info(self), StringValueCStr(geometry) };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleGeometryKernelInfo), &args);
return Qnil;
}
|
#unity_add(scale) ⇒ Object
Adds a given amount of the ‘Unity’ Convolution Kernel to the given pre-scaled and normalized Kernel.
153 154 155 156 157 158 159 |
# File 'ext/RMagick/rmkinfo.cpp', line 153
VALUE
KernelInfo_unity_add(VALUE self, VALUE scale)
{
GVL_STRUCT_TYPE(UnityAddKernelInfo) args = { get_kernel_info(self), NUM2DBL(scale) };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnityAddKernelInfo), &args);
return Qnil;
}
|