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
/// Metadata for an `Bitmap`.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BitmapData {
width: i32,
height: i32,
rowbytes: i32,
hasmask: i32,
}
impl BitmapData {
pub(crate) fn new(width: i32, height: i32, rowbytes: i32, hasmask: i32) -> Self {
Self {
width,
height,
rowbytes,
hasmask,
}
}
/// The number of pixels (or, columns) per row of the bitmap.
///
/// Each pixel is a single bit, and there may be more bytes (as determined by `row_bytes()`) in a
/// row than required to hold all the pixels.
pub fn width(&self) -> i32 {
self.width
}
/// The number of rows in the bitmap.
pub fn height(&self) -> i32 {
self.height
}
/// The number of bytes per row of the bitmap.
pub fn row_bytes(&self) -> i32 {
self.rowbytes
}
/// Whether the bitmap has a mask attached, via `set_mask_bitmap()`.
pub fn has_mask(&self) -> bool {
self.hasmask != 0
}
}