Skip to content

Commit

Permalink
Fix Scaling trait for Linear Scaler
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jun 5, 2024
1 parent 6b5714a commit 156a977
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["app"] }

[package]
name = "pic-scale"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
description = "High performance image scaling"
readme = "README.md"
Expand Down
19 changes: 15 additions & 4 deletions src/linear_scaler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ pub struct LinearScaler {
pub(crate) transfer_function: TransferFunction,
}

impl<'a> LinearScaler {
impl LinearScaler {
pub fn new(filter: ResamplingFunction) -> Self {
LinearScaler {
scaler: Scaler::new(filter),
transfer_function: TransferFunction::Srgb,
}
}
}

impl<'a> Scaling for LinearScaler {

pub fn set_threading_policy(&mut self, threading_policy: ThreadingPolicy) {
fn set_threading_policy(&mut self, threading_policy: ThreadingPolicy) {
self.scaler.threading_policy = threading_policy;
}

pub fn resize_rgb(&self, new_size: ImageSize, store: ImageStore<u8, 3>) -> ImageStore<u8, 3> {
fn resize_rgb(&self, new_size: ImageSize, store: ImageStore<u8, 3>) -> ImageStore<u8, 3> {
const CHANNELS: usize = 3;
let mut linear_store = ImageStore::<u8, CHANNELS>::alloc(store.width, store.height);
rgb_to_linear_u8(
Expand Down Expand Up @@ -58,7 +61,11 @@ impl<'a> LinearScaler {
gamma_store
}

pub fn resize_rgba(
fn resize_rgb_f32(&self, new_size: ImageSize, store: ImageStore<f32, 3>) -> ImageStore<f32, 3> {
self.scaler.resize_rgb_f32(new_size, store)
}

fn resize_rgba(
&self,
new_size: ImageSize,
store: ImageStore<u8, 4>,
Expand Down Expand Up @@ -103,4 +110,8 @@ impl<'a> LinearScaler {
}
gamma_store
}

fn resize_rgba_f32(&self, new_size: ImageSize, store: ImageStore<f32, 4>) -> ImageStore<f32, 4> {
self.scaler.resize_rgba_f32(new_size, store)
}
}

0 comments on commit 156a977

Please sign in to comment.