Bitmap

Struct Bitmap 

Source
pub struct Bitmap { /* private fields */ }
Expand description

A bitmap instance with ownership to the underlying data.

Implementations§

Source§

impl Bitmap

Source

pub fn new(size: Size<u32>, bgcolor: impl Into<ColorOrPattern>) -> Self

Allocates and returns a new width by height Bitmap filled with bgcolor.

Source

pub fn open(path: impl AsRef<str>) -> Result<Self, Error>

Open an image as a bitmap.

Source

pub fn clear(&self, bgcolor: impl Into<ColorOrPattern>)

Clears bitmap, filling with the given bgcolor.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn load(&self, path: impl AsRef<str>) -> Result<(), Error>

Loads the image at path into the previously allocated bitmap.

Source

pub fn rotated(&self, rotation: f32, scale: Vec2<f32>) -> Bitmap

Returns a new, rotated and scaled LCDBitmap based on the given bitmap.

Source

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.

Trait Implementations§

Source§

impl AsRef<Bitmap> for Bitmap

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Bitmap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Bitmap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Bitmap

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Bitmap

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Bitmap

Source§

impl Send for Bitmap

Source§

impl Sync for Bitmap

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.