mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
remove image crate dependency from gam Bitmap
This commit is contained in:
parent
66b0665d08
commit
767461fa16
2 changed files with 4 additions and 8 deletions
|
|
@ -36,8 +36,6 @@ qrcode = { version = "0.12", default-features = false }
|
|||
|
||||
#dither = "1.3.10" pending https://gitlab.com/efronlicht/dither/-/merge_requests/28
|
||||
dither = { git = "https://gitlab.com/nworbnhoj/dither", default-features = false, optional = true }
|
||||
# note: image version is matched to version used by dither
|
||||
image = { version = "0.23", default-features = false, features = ["png"], optional = true }
|
||||
|
||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||
utralib = {path = "../../utralib"}
|
||||
|
|
@ -45,6 +43,6 @@ utralib = {path = "../../utralib"}
|
|||
[features]
|
||||
debugprint = []
|
||||
tts = []
|
||||
ditherpunk = ["dither", "image"]
|
||||
ditherpunk = ["dither"]
|
||||
# default = ["debugprint"] # "debugprint"
|
||||
default = []
|
||||
|
|
|
|||
|
|
@ -236,11 +236,9 @@ impl From<[Option<Tile>; 6]> for Bitmap {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&image::RgbImage> for Bitmap {
|
||||
fn from(image: &image::RgbImage) -> Self {
|
||||
let pixels: Vec<RGB<u8>> = image.pixels().map(|p| RGB::from(p.0)).collect();
|
||||
let img = Img::new(pixels, image.width()).expect("failed to create dither Img");
|
||||
let img = img.convert_with(|rgb: RGB<u8>| rgb.convert_with(f64::from));
|
||||
impl From<Img<RGB<u8>>> for Bitmap {
|
||||
fn from(image: Img<RGB<u8>>) -> Self {
|
||||
let img = image.convert_with(|rgb: RGB<u8>| rgb.convert_with(f64::from));
|
||||
let bit_depth = 1;
|
||||
let quantize = dither::create_quantize_n_bits_func(bit_depth).unwrap();
|
||||
let bw_img = img.convert_with(|rgb| rgb.to_chroma_corrected_black_and_white());
|
||||
|
|
|
|||
Loading…
Reference in a new issue