-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hashbrown::HashMap is used to replace std::collections::HashMap. libm is used for float operations.
- Loading branch information
Showing
4 changed files
with
143 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "resize" | |
version = "0.8.0" | ||
description = "Simple image resampling library in pure Rust." | ||
authors = ["Kornel <[email protected]>", "Kagami Hiiragi <[email protected]>"] | ||
categories = ["graphics", "multimedia::images"] | ||
categories = ["graphics", "multimedia::images", "no_std"] | ||
keywords = ["resize", "scale", "resample", "image", "graphics"] | ||
documentation = "https://docs.rs/resize" | ||
homepage = "https://github.com/PistonDevelopers/resize" | ||
|
@@ -15,13 +15,17 @@ edition = "2021" | |
rust-version = "1.57" | ||
|
||
[features] | ||
default = ["rayon"] | ||
default = ["std"] | ||
std = ["rayon"] | ||
no_std = ["libm", "hashbrown"] | ||
|
||
[dev-dependencies] | ||
png = "0.17.7" | ||
|
||
[dependencies] | ||
rgb = "0.8.36" | ||
rgb = { version = "0.8.36", default-features = false } | ||
libm = { version = "0.2.7", optional = true } | ||
hashbrown = { version = "0.14.0", optional = true } | ||
rayon = { version = "1.7.0", optional = true } | ||
|
||
[package.metadata.docs.rs] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/// Alternative basic float operations for no_std | ||
pub(crate) trait FloatExt { | ||
fn floor(self) -> Self; | ||
fn ceil(self) -> Self; | ||
fn sqrt(self) -> Self; | ||
fn round(self) -> Self; | ||
fn abs(self) -> Self; | ||
fn trunc(self) -> Self; | ||
fn fract(self) -> Self; | ||
fn sin(self) -> Self; | ||
fn powi(self, n: i32) -> Self; | ||
} | ||
|
||
impl FloatExt for f32 { | ||
#[inline] | ||
fn floor(self) -> Self { | ||
libm::floorf(self) | ||
} | ||
#[inline] | ||
fn ceil(self) -> Self { | ||
libm::ceilf(self) | ||
} | ||
#[inline] | ||
fn sqrt(self) -> Self { | ||
libm::sqrtf(self) | ||
} | ||
#[inline] | ||
fn round(self) -> Self { | ||
libm::roundf(self) | ||
} | ||
#[inline] | ||
fn abs(self) -> Self { | ||
libm::fabsf(self) | ||
} | ||
#[inline] | ||
fn trunc(self) -> Self { | ||
libm::truncf(self) | ||
} | ||
#[inline] | ||
fn fract(self) -> Self { | ||
self - self.trunc() | ||
} | ||
#[inline] | ||
fn sin(self) -> Self { | ||
libm::sinf(self) | ||
} | ||
#[inline] | ||
fn powi(self, n: i32) -> Self { | ||
libm::powf(self, n as _) | ||
} | ||
} | ||
|
||
impl FloatExt for f64 { | ||
#[inline] | ||
fn floor(self) -> Self { | ||
libm::floor(self) | ||
} | ||
#[inline] | ||
fn ceil(self) -> Self { | ||
libm::ceil(self) | ||
} | ||
#[inline] | ||
fn sqrt(self) -> Self { | ||
libm::sqrt(self) | ||
} | ||
#[inline] | ||
fn round(self) -> Self { | ||
libm::round(self) | ||
} | ||
#[inline] | ||
fn abs(self) -> Self { | ||
libm::fabs(self) | ||
} | ||
#[inline] | ||
fn trunc(self) -> Self { | ||
libm::trunc(self) | ||
} | ||
#[inline] | ||
fn fract(self) -> Self { | ||
self - self.trunc() | ||
} | ||
#[inline] | ||
fn sin(self) -> Self { | ||
libm::sin(self) | ||
} | ||
#[inline] | ||
fn powi(self, n: i32) -> Self { | ||
libm::pow(self, n as _) | ||
} | ||
} |