Add ResolutionType type

This commit is contained in:
5ohue
2024-05-11 14:31:53 +03:00
parent 7db8314e5a
commit baac3cbf59
3 changed files with 42 additions and 1 deletions

View File

@ -12,6 +12,7 @@ mod metric_type;
mod orientation_type; mod orientation_type;
mod pixel_interpolate_method; mod pixel_interpolate_method;
mod rendering_intent; mod rendering_intent;
mod resolution_type;
mod resource_type; mod resource_type;
pub use self::alpha_channel_option::AlphaChannelOption; 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::orientation_type::OrientationType;
pub use self::pixel_interpolate_method::PixelInterpolateMethod; pub use self::pixel_interpolate_method::PixelInterpolateMethod;
pub use self::rendering_intent::RenderingIntent; pub use self::rendering_intent::RenderingIntent;
pub use self::resolution_type::ResolutionType;
pub use self::resource_type::ResourceType; pub use self::resource_type::ResourceType;

View 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();
}
}

View File

@ -45,6 +45,7 @@ use crate::{
OrientationType, OrientationType,
PixelInterpolateMethod, PixelInterpolateMethod,
RenderingIntent, RenderingIntent,
ResolutionType,
ResourceType ResourceType
}; };
@ -1195,7 +1196,7 @@ impl MagickWand {
get_image_rendering_intent, set_image_rendering_intent, MagickGetImageRenderingIntent, MagickSetImageRenderingIntent, RenderingIntent get_image_rendering_intent, set_image_rendering_intent, MagickGetImageRenderingIntent, MagickSetImageRenderingIntent, RenderingIntent
get_image_scene, set_image_scene, MagickGetImageScene, MagickSetImageScene, usize get_image_scene, set_image_scene, MagickGetImageScene, MagickSetImageScene, usize
get_image_type, set_image_type, MagickGetImageType, MagickSetImageType, bindings::ImageType 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_interlace_scheme, set_interlace_scheme, MagickGetInterlaceScheme, MagickSetInterlaceScheme, InterlaceType
get_interpolate_method, set_interpolate_method, MagickGetInterpolateMethod, MagickSetInterpolateMethod, PixelInterpolateMethod get_interpolate_method, set_interpolate_method, MagickGetInterpolateMethod, MagickSetInterpolateMethod, PixelInterpolateMethod
get_iterator_index, set_iterator_index, MagickGetIteratorIndex, MagickSetIteratorIndex, isize get_iterator_index, set_iterator_index, MagickGetIteratorIndex, MagickSetIteratorIndex, isize