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
use bytes::Bytes;

#[derive(Copy, Clone, Debug)]
pub enum PixelFormat {
    Invalid,
    ARgb32,
    Rgb24,
    A8,
    A1,
    Rgb16_565,
    Rgb30,
}

impl Default for PixelFormat {
    fn default() -> Self {
        PixelFormat::ARgb32
    }
}

#[derive(Debug, Clone)]
pub struct ImageData {
    pub format: PixelFormat,
    pub width: u32,
    pub height: u32,
    pub data: Bytes,
}

impl ImageData {
    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(),
        }
    }
}