diff --git a/bingus/src/img.rs b/bingus/src/img.rs index 14995d4..bb13e63 100644 --- a/bingus/src/img.rs +++ b/bingus/src/img.rs @@ -1 +1,3 @@ -pub mod image; +mod image; +pub use image::ImageBuffer as Image; +pub use image::*; diff --git a/bingus/src/img/image.rs b/bingus/src/img/image.rs index a4a657f..ceb852d 100644 --- a/bingus/src/img/image.rs +++ b/bingus/src/img/image.rs @@ -1,13 +1,13 @@ use std::ops::{BitOr, Deref, Shl}; -use image::{ImageBuffer, Pixel}; +pub use image::*; use num::{traits::ToBytes, Zero}; use crate::{Bendable, IntoDataBytes, TryFromDataBytes}; impl IntoDataBytes for ImageBuffer> where - Vec

: Deref, + Vec: Deref, P::Subpixel: ToBytes, { fn into_bytes(self) -> crate::Bytes { @@ -24,7 +24,7 @@ pub struct Dimensions { impl TryFromDataBytes for ImageBuffer> where - Vec

: Deref, + Vec: Deref, P::Subpixel: ToBytes + Zero + Shl + BitOr, { @@ -54,7 +54,7 @@ where impl Bendable for ImageBuffer> where - Vec

: Deref, + Vec: Deref, P::Subpixel: ToBytes + Zero + Shl + BitOr, { @@ -64,3 +64,27 @@ where self } } + +#[cfg(test)] +mod tests { + #[cfg(test)] + mod ser_de { + use super::super::{Dimensions, IntoDataBytes, TryFromDataBytes}; + use image::RgbImage; + + #[test] + fn empty() { + let image = RgbImage::new(0, 0); + assert_eq!( + Ok(image.clone()), + RgbImage::try_from_bytes( + image.into_bytes(), + Dimensions { + width: 0, + height: 0 + } + ) + ) + } + } +}