pub struct Bitmap { /* private fields */ }Expand description
A bitmap instance with ownership to the underlying data.
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn new(size: Size<u32>, bgcolor: impl Into<ColorOrPattern>) -> Self
pub fn new(size: Size<u32>, bgcolor: impl Into<ColorOrPattern>) -> Self
Allocates and returns a new width by height Bitmap filled with bgcolor.
Sourcepub fn clear(&self, bgcolor: impl Into<ColorOrPattern>)
pub fn clear(&self, bgcolor: impl Into<ColorOrPattern>)
Clears bitmap, filling with the given bgcolor.
Sourcepub fn set_mask(&self, mask: impl AsRef<Bitmap>) -> Result<(), Error>
pub fn set_mask(&self, mask: impl AsRef<Bitmap>) -> Result<(), Error>
Sets a mask image for the given bitmap. The set mask must be the same size as the target bitmap.
Sourcepub fn get_mask(&self) -> Ref<'_, Bitmap>
pub fn get_mask(&self) -> Ref<'_, Bitmap>
Gets a mask image for the given bitmap. If the image doesn’t have a mask, getBitmapMask returns NULL.
Sourcepub fn check_mask_collision(
&self,
x1: i32,
y1: i32,
flip1: BitmapFlip,
other: impl AsRef<Bitmap>,
x2: i32,
y2: i32,
flip2: BitmapFlip,
rect: SideOffsets<i32>,
) -> bool
pub fn check_mask_collision( &self, x1: i32, y1: i32, flip1: BitmapFlip, other: impl AsRef<Bitmap>, x2: i32, y2: i32, flip2: BitmapFlip, rect: SideOffsets<i32>, ) -> bool
Returns true if any of the opaque pixels in self when positioned at x1, y1 with flip1 overlap any of the opaque pixels in other at x2, y2 with flip2 within the non-empty rect, or false if no pixels overlap or if one or both fall completely outside of rect.
Sourcepub fn get_bitmap_data(&self) -> BitmapData<'_>
pub fn get_bitmap_data(&self) -> BitmapData<'_>
Gets various info about bitmap including its width and height and raw pixel data. The data is 1 bit per pixel packed format, in MSB order; in other words, the high bit of the first byte in data is the top left pixel of the image. If the bitmap has a mask, a pointer to its data is returned in mask, else NULL is returned.
Sourcepub fn load(&self, path: impl AsRef<str>) -> Result<(), Error>
pub fn load(&self, path: impl AsRef<str>) -> Result<(), Error>
Loads the image at path into the previously allocated bitmap.
Sourcepub fn rotated(&self, rotation: f32, scale: Vec2<f32>) -> Bitmap
pub fn rotated(&self, rotation: f32, scale: Vec2<f32>) -> Bitmap
Returns a new, rotated and scaled LCDBitmap based on the given bitmap.
Sourcepub fn get_color_pattern(&self, pos: Vec2<i32>) -> ColorPatternData
pub fn get_color_pattern(&self, pos: Vec2<i32>) -> ColorPatternData
Get color as an 8 x 8 pattern using the given bitmap. x, y indicates the top left corner of the 8 x 8 pattern.