Add AutoThresholdMethod type
This commit is contained in:
22
src/types/auto_threshold_method.rs
Normal file
22
src/types/auto_threshold_method.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum AutoThresholdMethod {
|
||||||
|
Undefined = bindings::AutoThresholdMethod_UndefinedThresholdMethod,
|
||||||
|
Kapur = bindings::AutoThresholdMethod_KapurThresholdMethod,
|
||||||
|
OTSU = bindings::AutoThresholdMethod_OTSUThresholdMethod,
|
||||||
|
Triangle = bindings::AutoThresholdMethod_TriangleThresholdMethod,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AutoThresholdMethod {
|
||||||
|
fn default() -> Self {
|
||||||
|
return AutoThresholdMethod::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AutoThresholdMethod> for bindings::AutoThresholdMethod {
|
||||||
|
fn from(value: AutoThresholdMethod) -> Self {
|
||||||
|
return value as bindings::AutoThresholdMethod;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
mod align_type;
|
mod align_type;
|
||||||
mod alpha_channel_option;
|
mod alpha_channel_option;
|
||||||
|
mod auto_threshold_method;
|
||||||
mod clip_path_units;
|
mod clip_path_units;
|
||||||
mod colorspace_type;
|
mod colorspace_type;
|
||||||
mod composite_operator;
|
mod composite_operator;
|
||||||
@ -29,6 +30,7 @@ mod style_type;
|
|||||||
|
|
||||||
pub use self::align_type::AlignType;
|
pub use self::align_type::AlignType;
|
||||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||||
|
pub use self::auto_threshold_method::AutoThresholdMethod;
|
||||||
pub use self::clip_path_units::ClipPathUnits;
|
pub use self::clip_path_units::ClipPathUnits;
|
||||||
pub use self::colorspace_type::ColorspaceType;
|
pub use self::colorspace_type::ColorspaceType;
|
||||||
pub use self::composite_operator::CompositeOperator;
|
pub use self::composite_operator::CompositeOperator;
|
||||||
|
|||||||
@ -32,6 +32,7 @@ use super::{MagickTrue, MagickFalse};
|
|||||||
use super::{DrawingWand, PixelWand};
|
use super::{DrawingWand, PixelWand};
|
||||||
use crate::{
|
use crate::{
|
||||||
AlphaChannelOption,
|
AlphaChannelOption,
|
||||||
|
AutoThresholdMethod,
|
||||||
ColorspaceType,
|
ColorspaceType,
|
||||||
CompositeOperator,
|
CompositeOperator,
|
||||||
CompressionType,
|
CompressionType,
|
||||||
@ -1286,8 +1287,8 @@ impl MagickWand {
|
|||||||
/// down to a binary black & white image. Included algorithms are
|
/// down to a binary black & white image. Included algorithms are
|
||||||
/// Kapur, Otsu, and Triangle methods.
|
/// Kapur, Otsu, and Triangle methods.
|
||||||
/// See <https://imagemagick.org/api/magick-image.php#MagickAutoThresholdImage> for more information.
|
/// See <https://imagemagick.org/api/magick-image.php#MagickAutoThresholdImage> for more information.
|
||||||
pub fn auto_threshold(&self, method: bindings::AutoThresholdMethod) -> Result<()> {
|
pub fn auto_threshold(&self, method: AutoThresholdMethod) -> Result<()> {
|
||||||
match unsafe { bindings::MagickAutoThresholdImage(self.wand, method) } {
|
match unsafe { bindings::MagickAutoThresholdImage(self.wand, method.into()) } {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError("unable to auto threshold image")),
|
_ => Err(MagickError("unable to auto threshold image")),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user