Add set_image_mask function
This commit is contained in:
@ -25,6 +25,7 @@ mod magick_function;
|
|||||||
mod metric_type;
|
mod metric_type;
|
||||||
mod orientation_type;
|
mod orientation_type;
|
||||||
mod pixel_interpolate_method;
|
mod pixel_interpolate_method;
|
||||||
|
mod pixel_mask;
|
||||||
mod rendering_intent;
|
mod rendering_intent;
|
||||||
mod resolution_type;
|
mod resolution_type;
|
||||||
mod resource_type;
|
mod resource_type;
|
||||||
@ -59,6 +60,7 @@ pub use self::magick_function::MagickFunction;
|
|||||||
pub use self::metric_type::MetricType;
|
pub use self::metric_type::MetricType;
|
||||||
pub use self::orientation_type::OrientationType;
|
pub use self::orientation_type::OrientationType;
|
||||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||||
|
pub use self::pixel_mask::PixelMask;
|
||||||
pub use self::rendering_intent::RenderingIntent;
|
pub use self::rendering_intent::RenderingIntent;
|
||||||
pub use self::resolution_type::ResolutionType;
|
pub use self::resolution_type::ResolutionType;
|
||||||
pub use self::resource_type::ResourceType;
|
pub use self::resource_type::ResourceType;
|
||||||
|
|||||||
22
src/types/pixel_mask.rs
Normal file
22
src/types/pixel_mask.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum PixelMask {
|
||||||
|
Undefined = bindings::PixelMask_UndefinedPixelMask,
|
||||||
|
Read = bindings::PixelMask_ReadPixelMask,
|
||||||
|
Write = bindings::PixelMask_WritePixelMask,
|
||||||
|
Composite = bindings::PixelMask_CompositePixelMask,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for PixelMask {
|
||||||
|
fn default() -> Self {
|
||||||
|
return PixelMask::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<PixelMask> for bindings::PixelMask {
|
||||||
|
fn from(value: PixelMask) -> Self {
|
||||||
|
return value as bindings::PixelMask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,6 +51,7 @@ use crate::{
|
|||||||
MorphologyMethod,
|
MorphologyMethod,
|
||||||
OrientationType,
|
OrientationType,
|
||||||
PixelInterpolateMethod,
|
PixelInterpolateMethod,
|
||||||
|
PixelMask,
|
||||||
RenderingIntent,
|
RenderingIntent,
|
||||||
ResolutionType,
|
ResolutionType,
|
||||||
ResourceType,
|
ResourceType,
|
||||||
@ -1239,6 +1240,27 @@ impl MagickWand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets image clip mask.
|
||||||
|
///
|
||||||
|
/// * `pixel_mask`: type of mask, Read or Write.
|
||||||
|
/// * `clip_mask`: the clip_mask wand.
|
||||||
|
pub fn set_image_mask(
|
||||||
|
&mut self,
|
||||||
|
pixel_mask: PixelMask,
|
||||||
|
clip_mask: &MagickWand
|
||||||
|
) -> Result<()> {
|
||||||
|
match unsafe {
|
||||||
|
bindings::MagickSetImageMask(
|
||||||
|
self.wand,
|
||||||
|
pixel_mask.into(),
|
||||||
|
clip_mask.wand
|
||||||
|
)
|
||||||
|
} {
|
||||||
|
MagickTrue => Ok(()),
|
||||||
|
_ => Err(MagickError("failed to set image mask")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set image channel mask
|
/// Set image channel mask
|
||||||
pub fn set_image_channel_mask(
|
pub fn set_image_channel_mask(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|||||||
Reference in New Issue
Block a user