1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![deny(missing_docs)]
use color_processing::Color;
use image::GenericImageView;
fn colors_from_file(filepath: &str) -> Vec<Color> {
let image = image::open(filepath).unwrap();
image
.pixels()
.map(|pixel| {
let data = pixel.2.data;
Color::new_rgba(data[0], data[1], data[2], data[3])
})
.collect()
}
pub fn colors_from_bytes(bytes: Vec<u8>) -> Vec<Color> {
let img = image::load_from_memory(&bytes).expect("Cannot load image from bytes.");
img.pixels()
.map(|pixel| {
let data = pixel.2.data;
Color::new_rgba(data[0], data[1], data[2], data[3])
})
.collect()
}
pub mod constants;
pub mod region;
pub mod space;
pub use color_processing;
pub use image;
pub mod prelude {
pub use crate::region::Region;
pub use crate::space::Space;
pub use color_processing::Color;
pub use image::GenericImageView;
}