Skip to content

Commit

Permalink
wip: perform large refactor of image optimizations, image loader and …
Browse files Browse the repository at this point in the history
…image struct for #25
  • Loading branch information
THEGOLDENPRO committed Jan 12, 2025
1 parent 49fba8d commit e958ecd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/image/optimization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum ImageOptimization {
/// NOTE: "The image's aspect ratio is preserved. The image is scaled to the maximum
/// possible size that fits within the bounds specified by the width and height." ~ Image Crate
Downsample(u32, u32),
Upsample(u32, u32)
}

impl ImageOptimization {
Expand All @@ -35,6 +36,7 @@ impl ImageOptimization {
image::imageops::FilterType::Lanczos3
)
},
_ => image
}
}

Expand All @@ -43,12 +45,14 @@ impl ImageOptimization {
ImageOptimization::Downsample(width, height) => {
fast_downsample(pixels, image_size, (*width, *height), has_alpha)
},
_ => (pixels, *image_size)
}
}

pub fn id(&self) -> &str {
match self {
ImageOptimization::Downsample(_, _) => "downsample",
ImageOptimization::Upsample(_, _) => "upsample",
}
}
}
Expand All @@ -57,6 +61,7 @@ impl Display for ImageOptimization {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ImageOptimization::Downsample(_, _) => write!(f, "Downsample"),
ImageOptimization::Upsample(_, _) => write!(f, "Upsample"),
}
}
}
Expand Down

0 comments on commit e958ecd

Please sign in to comment.