Add ResolutionType type
This commit is contained in:
@ -12,6 +12,7 @@ mod metric_type;
|
||||
mod orientation_type;
|
||||
mod pixel_interpolate_method;
|
||||
mod rendering_intent;
|
||||
mod resolution_type;
|
||||
mod resource_type;
|
||||
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
@ -28,4 +29,5 @@ 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::resolution_type::ResolutionType;
|
||||
pub use self::resource_type::ResourceType;
|
||||
|
||||
38
src/types/resolution_type.rs
Normal file
38
src/types/resolution_type.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum ResolutionType {
|
||||
Undefined = bindings::ResolutionType_UndefinedResolution,
|
||||
PixelsPerInch = bindings::ResolutionType_PixelsPerInchResolution,
|
||||
PixelsPerCentimeter = bindings::ResolutionType_PixelsPerCentimeterResolution,
|
||||
}
|
||||
|
||||
impl Default for ResolutionType {
|
||||
fn default() -> Self {
|
||||
return ResolutionType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResolutionType> for bindings::ResolutionType {
|
||||
fn from(value: ResolutionType) -> Self {
|
||||
return value as bindings::ResolutionType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ResolutionType> for ResolutionType {
|
||||
fn from(value: bindings::ResolutionType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `ResolutionType` has the same repr as `bindings::ResolutionType` - u32
|
||||
*
|
||||
* If `value` is less than PixelsPerCentimeter than it is in the vaild range and can be safely
|
||||
* reinterpreted as `ResolutionType`
|
||||
*/
|
||||
if value <= bindings::ResolutionType_PixelsPerCentimeterResolution {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return ResolutionType::default();
|
||||
}
|
||||
}
|
||||
@ -45,6 +45,7 @@ use crate::{
|
||||
OrientationType,
|
||||
PixelInterpolateMethod,
|
||||
RenderingIntent,
|
||||
ResolutionType,
|
||||
ResourceType
|
||||
};
|
||||
|
||||
@ -1195,7 +1196,7 @@ impl MagickWand {
|
||||
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
|
||||
get_image_units, set_image_units, MagickGetImageUnits, MagickSetImageUnits, ResolutionType
|
||||
get_interlace_scheme, set_interlace_scheme, MagickGetInterlaceScheme, MagickSetInterlaceScheme, InterlaceType
|
||||
get_interpolate_method, set_interpolate_method, MagickGetInterpolateMethod, MagickSetInterpolateMethod, PixelInterpolateMethod
|
||||
get_iterator_index, set_iterator_index, MagickGetIteratorIndex, MagickSetIteratorIndex, isize
|
||||
|
||||
Reference in New Issue
Block a user