Add RenderingIntent type
This commit is contained in:
@ -11,6 +11,7 @@ mod interlace_type;
|
||||
mod metric_type;
|
||||
mod orientation_type;
|
||||
mod pixel_interpolate_method;
|
||||
mod rendering_intent;
|
||||
mod resource_type;
|
||||
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
@ -26,4 +27,5 @@ pub use self::interlace_type::InterlaceType;
|
||||
pub use self::metric_type::MetricType;
|
||||
pub use self::orientation_type::OrientationType;
|
||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||
pub use self::rendering_intent::RenderingIntent;
|
||||
pub use self::resource_type::ResourceType;
|
||||
|
||||
40
src/types/rendering_intent.rs
Normal file
40
src/types/rendering_intent.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum RenderingIntent {
|
||||
Undefined = bindings::RenderingIntent_UndefinedIntent,
|
||||
Saturation = bindings::RenderingIntent_SaturationIntent,
|
||||
Perceptual = bindings::RenderingIntent_PerceptualIntent,
|
||||
Absolute = bindings::RenderingIntent_AbsoluteIntent,
|
||||
Relative = bindings::RenderingIntent_RelativeIntent,
|
||||
}
|
||||
|
||||
impl Default for RenderingIntent {
|
||||
fn default() -> Self {
|
||||
return RenderingIntent::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RenderingIntent> for bindings::RenderingIntent {
|
||||
fn from(value: RenderingIntent) -> Self {
|
||||
return value as bindings::RenderingIntent;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::RenderingIntent> for RenderingIntent {
|
||||
fn from(value: bindings::RenderingIntent) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `RenderingIntent` has the same repr as `bindings::RenderingIntent` - u32
|
||||
*
|
||||
* If `value` is less than Relative than it is in the vaild range and can be safely
|
||||
* reinterpreted as `RenderingIntent`
|
||||
*/
|
||||
if value <= bindings::RenderingIntent_RelativeIntent {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return RenderingIntent::default();
|
||||
}
|
||||
}
|
||||
@ -44,6 +44,7 @@ use crate::{
|
||||
MetricType,
|
||||
OrientationType,
|
||||
PixelInterpolateMethod,
|
||||
RenderingIntent,
|
||||
ResourceType
|
||||
};
|
||||
|
||||
@ -1191,7 +1192,7 @@ impl MagickWand {
|
||||
get_image_interpolate_method, set_image_interpolate_method, MagickGetImageInterpolateMethod, MagickSetImageInterpolateMethod, PixelInterpolateMethod
|
||||
get_image_iterations, set_image_iterations, MagickGetImageIterations, MagickSetImageIterations, usize
|
||||
get_image_orientation, set_image_orientation, MagickGetImageOrientation, MagickSetImageOrientation, OrientationType
|
||||
get_image_rendering_intent, set_image_rendering_intent, MagickGetImageRenderingIntent, MagickSetImageRenderingIntent, bindings::RenderingIntent
|
||||
get_image_rendering_intent, set_image_rendering_intent, MagickGetImageRenderingIntent, MagickSetImageRenderingIntent, RenderingIntent
|
||||
get_image_scene, set_image_scene, MagickGetImageScene, MagickSetImageScene, usize
|
||||
get_image_type, set_image_type, MagickGetImageType, MagickSetImageType, bindings::ImageType
|
||||
get_image_units, set_image_units, MagickGetImageUnits, MagickSetImageUnits, bindings::ResolutionType
|
||||
|
||||
Reference in New Issue
Block a user