pub mod spatial;
use crate::common::types::CropRegion;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TransformOp {
None,
HFlip,
VFlip,
Transpose,
Transverse,
Rot90,
Rot180,
Rot270,
}
#[derive(Debug, Clone)]
pub struct TransformInfo {
pub transform: TransformOp,
}
impl Default for TransformInfo {
fn default() -> Self {
Self {
transform: TransformOp::None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum MarkerCopyMode {
#[default]
All,
None,
IccOnly,
}
impl From<bool> for MarkerCopyMode {
fn from(value: bool) -> Self {
if value {
MarkerCopyMode::All
} else {
MarkerCopyMode::None
}
}
}
pub struct TransformOptions {
pub op: TransformOp,
pub perfect: bool,
pub trim: bool,
pub crop: Option<CropRegion>,
pub grayscale: bool,
pub no_output: bool,
pub progressive: bool,
pub arithmetic: bool,
pub optimize: bool,
pub copy_markers: MarkerCopyMode,
#[allow(clippy::type_complexity)]
pub custom_filter: Option<Box<dyn Fn(&mut [i16; 64], usize, usize, usize)>>,
}
impl Default for TransformOptions {
fn default() -> Self {
Self {
op: TransformOp::None,
perfect: false,
trim: false,
crop: None,
grayscale: false,
no_output: false,
progressive: false,
arithmetic: false,
optimize: false,
copy_markers: MarkerCopyMode::All,
custom_filter: None,
}
}
}
impl std::fmt::Debug for TransformOptions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TransformOptions")
.field("op", &self.op)
.field("perfect", &self.perfect)
.field("trim", &self.trim)
.field("crop", &self.crop)
.field("grayscale", &self.grayscale)
.field("no_output", &self.no_output)
.field("progressive", &self.progressive)
.field("arithmetic", &self.arithmetic)
.field("optimize", &self.optimize)
.field("copy_markers", &self.copy_markers)
.field(
"custom_filter",
&self.custom_filter.as_ref().map(|_| "<filter fn>"),
)
.finish()
}
}