ext/RMagick/rmkinfo.c in rmagick-3.0.0 vs ext/RMagick/rmkinfo.c in rmagick-3.1.0
- old
+ new
@@ -19,12 +19,12 @@
*/
static void
rm_kernel_info_destroy(void *kernel)
{
- if (kernel)
- DestroyKernelInfo((KernelInfo*)kernel);
+ if (kernel)
+ DestroyKernelInfo((KernelInfo*)kernel);
}
/**
* Create a KernelInfo object.
*
@@ -34,11 +34,11 @@
* @return a new KernelInfo object
*/
VALUE
KernelInfo_alloc(VALUE class)
{
- return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
+ return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
}
/**
* KernelInfo object constructor
*
@@ -50,37 +50,39 @@
* @return self
*/
VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
- KernelInfo *kernel;
+ KernelInfo *kernel;
- Check_Type(kernel_string, T_STRING);
+ Check_Type(kernel_string, T_STRING);
- kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
+ kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
- if (kernel == NULL)
- rb_raise(rb_eRuntimeError, "failed to parse kernel string");
+ if (kernel == NULL)
+ rb_raise(rb_eRuntimeError, "failed to parse kernel string");
- DATA_PTR(self) = kernel;
+ DATA_PTR(self) = kernel;
- return self;
+ return self;
}
/**
* Zero kerne NaNs.
*
* Ruby usage:
* - @verbatim KernelInfo#zero_nans @endverbatim
*
* @param self this object
+ * @deprecated This method has been deprecated.
*/
VALUE
KernelInfo_zero_nans(VALUE self)
{
- ZeroKernelNans((KernelInfo*)DATA_PTR(self));
- return Qnil;
+ rb_warning("KernelInfo#zero_nans is deprecated");
+ ZeroKernelNans((KernelInfo*)DATA_PTR(self));
+ return Qnil;
}
/**
* Adds a given amount of the 'Unity' Convolution Kernel to the given pre-scaled and normalized Kernel.
*
@@ -91,30 +93,32 @@
* @param scale scale to add
*/
VALUE
KernelInfo_unity_add(VALUE self, VALUE scale)
{
- if (!FIXNUM_P(scale))
- Check_Type(scale, T_FLOAT);
+ if (!FIXNUM_P(scale))
+ Check_Type(scale, T_FLOAT);
- UnityAddKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale));
- return Qnil;
+ UnityAddKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale));
+ return Qnil;
}
/**
* Dumps KernelInfo object to stderr
*
* Ruby usage:
* - @verbatim KernelInfo#show @endverbatim
*
* @param self this object
+ * @deprecated This method has been deprecated.
*/
VALUE
KernelInfo_show(VALUE self)
{
- ShowKernelInfo((KernelInfo*)DATA_PTR(self));
- return Qnil;
+ rb_warning("KernelInfo#show is deprecated");
+ ShowKernelInfo((KernelInfo*)DATA_PTR(self));
+ return Qnil;
}
/**
* Scales the given kernel list by the given amount, with or without normalization
* of the sum of the kernel values (as per given flags).
@@ -128,22 +132,22 @@
* @param self this object
*/
VALUE
KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
{
- GeometryFlags geoflags;
+ GeometryFlags geoflags;
- if (!FIXNUM_P(scale))
- Check_Type(scale, T_FLOAT);
+ if (!FIXNUM_P(scale))
+ Check_Type(scale, T_FLOAT);
- if (rb_obj_is_instance_of(flags, Class_GeometryFlags))
- VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
- else
- rb_raise(rb_eArgError, "expected Fixnum or Magick::GeometryFlags to specify flags");
+ if (rb_obj_is_instance_of(flags, Class_GeometryFlags))
+ VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
+ else
+ rb_raise(rb_eArgError, "expected Integer or Magick::GeometryFlags to specify flags");
- ScaleKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags);
- return Qnil;
+ ScaleKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags);
+ return Qnil;
}
/**
* 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.
@@ -155,13 +159,13 @@
* @param self this object
*/
VALUE
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
{
- Check_Type(geometry, T_STRING);
- ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
- return Qnil;
+ Check_Type(geometry, T_STRING);
+ ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
+ return Qnil;
}
/**
* Creates a new clone of the object so that its can be modified without effecting the original.
*
@@ -172,12 +176,12 @@
* @return new KernelInfo instance
*/
VALUE
KernelInfo_clone(VALUE self)
{
- KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
- return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
+ KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
+ return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
}
/**
* Create new instance of KernelInfo with one of the 'named' built-in types of
* kernels used for special purposes such as gaussian blurring, skeleton
@@ -222,26 +226,27 @@
* Magick::ChebyshevKernel
* Magick::ManhattanKernel
* Magick::OctagonalKernel
* Magick::EuclideanKernel
* Magick::UserDefinedKernel
+ * Magick::BinomialKernel
* @param geometry geometry to pass to default kernel
* @return KernelInfo instance
*/
VALUE
KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
{
- KernelInfo *kernel;
- KernelInfoType kernel_type;
- GeometryInfo info;
+ KernelInfo *kernel;
+ KernelInfoType kernel_type;
+ GeometryInfo info;
- Check_Type(geometry, T_STRING);
- VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
- ParseGeometry(StringValueCStr(geometry), &info);
+ Check_Type(geometry, T_STRING);
+ VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
+ ParseGeometry(StringValueCStr(geometry), &info);
- kernel = AcquireKernelBuiltIn(kernel_type, &info);
+ kernel = AcquireKernelBuiltIn(kernel_type, &info);
- if (!kernel)
- rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
+ if (!kernel)
+ rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
- return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
+ return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
}