primitives/foundation/
image.rs

1use bytes::Bytes;
2
3/// Describes pixel format properties
4#[derive(Copy, Clone, Debug)]
5pub enum PixelFormat {
6    /// Invalid pixel format
7    Invalid,
8    /// Represents ARgb32 format
9    ARgb32,
10    /// Represents Rgb24 format
11    Rgb24,
12    /// Represents A8 format
13    A8,
14    /// Represents A1 format
15    A1,
16    /// Represents Rgb16_565 format
17    Rgb16_565,
18    /// Represents Rgb30 format
19    Rgb30,
20}
21
22impl Default for PixelFormat {
23    fn default() -> Self {
24        PixelFormat::ARgb32
25    }
26}
27
28/// Represens image data with parameters
29#[derive(Debug, Clone)]
30pub struct ImageData {
31    /// Image format
32    pub format: PixelFormat,
33    /// Image width
34    pub width: u32,
35    /// Image height
36    pub height: u32,
37    /// Image data
38    pub data: Bytes,
39}
40
41impl ImageData {
42    /// Create image data with params
43    pub fn new(format: PixelFormat, width: u32, height: u32, data: Bytes) -> Self {
44        Self {
45            format,
46            width,
47            height,
48            data,
49        }
50    }
51}
52
53impl Default for ImageData {
54    fn default() -> Self {
55        Self {
56            format: Default::default(),
57            width: 0,
58            height: 0,
59            data: Default::default(),
60        }
61    }
62}