use lb::color;
use lb::img;
use lb::mat;
use lb::mat::Matrix;
#[test]
fn img_from_bytes() {
let bytes = [
0, 1, 2, 3, 4, 5, 6, 7, 8, ];
{
let img = img::ImgVec::from_bytes(&bytes, (3, 1).into()).unwrap();
let expected = [
color::Rgb::new(0, 1, 2),
color::Rgb::new(3, 4, 5),
color::Rgb::new(6, 7, 8),
];
assert_eq!(img.as_slice(), expected);
assert_eq!(img.size(), (3, 1).into());
}
{
let img = img::ImgVec::from_bytes(&bytes, (1, 3).into()).unwrap();
let expected = [
color::Rgb::new(0, 1, 2),
color::Rgb::new(3, 4, 5),
color::Rgb::new(6, 7, 8),
];
assert_eq!(img.as_slice(), expected);
assert_eq!(img.size(), (1, 3).into());
}
{
let err = img::ImgVec::from_bytes(&bytes, (1, 1).into());
assert_eq!(err, Err(mat::Error::InvalidSize));
}
}