Add artifact related functions
This makes it possible to blend images with user configurable percent (see `set_image_artifact` documentation)
This commit is contained in:
@ -15,6 +15,7 @@ mod pixel_interpolate_method;
|
||||
mod rendering_intent;
|
||||
mod resolution_type;
|
||||
mod resource_type;
|
||||
mod statistic_type;
|
||||
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
pub use self::colorspace_type::ColorspaceType;
|
||||
@ -33,3 +34,4 @@ 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;
|
||||
pub use self::statistic_type::StatisticType;
|
||||
|
||||
46
src/types/statistic_type.rs
Normal file
46
src/types/statistic_type.rs
Normal file
@ -0,0 +1,46 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum StatisticType {
|
||||
Undefined = bindings::StatisticType_UndefinedStatistic,
|
||||
Gradient = bindings::StatisticType_GradientStatistic,
|
||||
Maximum = bindings::StatisticType_MaximumStatistic,
|
||||
Mean = bindings::StatisticType_MeanStatistic,
|
||||
Median = bindings::StatisticType_MedianStatistic,
|
||||
Minimum = bindings::StatisticType_MinimumStatistic,
|
||||
Mode = bindings::StatisticType_ModeStatistic,
|
||||
Nonpeak = bindings::StatisticType_NonpeakStatistic,
|
||||
RootMeanSquare = bindings::StatisticType_RootMeanSquareStatistic,
|
||||
StandardDeviation = bindings::StatisticType_StandardDeviationStatistic,
|
||||
Contrast = bindings::StatisticType_ContrastStatistic,
|
||||
}
|
||||
|
||||
impl Default for StatisticType {
|
||||
fn default() -> Self {
|
||||
return StatisticType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StatisticType> for bindings::StatisticType {
|
||||
fn from(value: StatisticType) -> Self {
|
||||
return value as bindings::StatisticType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::StatisticType> for StatisticType {
|
||||
fn from(value: bindings::StatisticType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `StatisticType` has the same repr as `bindings::StatisticType` - u32
|
||||
*
|
||||
* If `value` is less than Contrast than it is in the vaild range and can be safely
|
||||
* reinterpreted as `StatisticType`
|
||||
*/
|
||||
if value <= bindings::StatisticType_ContrastStatistic {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return StatisticType::default();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user