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
59
60
61
62
use bytes::Bytes;
/// Describes pixel format properties
#[derive(Copy, Clone, Debug)]
pub enum PixelFormat {
/// Invalid pixel format
Invalid,
/// Represents ARgb32 format
ARgb32,
/// Represents Rgb24 format
Rgb24,
/// Represents A8 format
A8,
/// Represents A1 format
A1,
/// Represents Rgb16_565 format
Rgb16_565,
/// Represents Rgb30 format
Rgb30,
}
impl Default for PixelFormat {
fn default() -> Self {
PixelFormat::ARgb32
}
}
/// Represens image data with parameters
#[derive(Debug, Clone)]
pub struct ImageData {
/// Image format
pub format: PixelFormat,
/// Image width
pub width: u32,
/// Image height
pub height: u32,
/// Image data
pub data: Bytes,
}
impl ImageData {
/// Create image data with params
pub fn new(format: PixelFormat, width: u32, height: u32, data: Bytes) -> Self {
Self {
format,
width,
height,
data,
}
}
}
impl Default for ImageData {
fn default() -> Self {
Self {
format: Default::default(),
width: 0,
height: 0,
data: Default::default(),
}
}
}