pub struct UnownedBitmapMut<'a> { /* private fields */ }Expand description
A mutable Bitmap that is not owned by the application, so can only be used as a borrowed
BitmapRef.
A UnownedBitmapRef can be cloned which is a shallow clone that produces access to another
mutable borrow on the unowned Bitmap.
Methods from Deref<Target = BitmapRef>§
Sourcepub fn load_file(&mut self, path: &str) -> Result<(), Error>
pub fn load_file(&mut self, path: &str) -> Result<(), Error>
Loads the image at path into the previously allocated BitmapRef.
Sourcepub fn data(&self) -> BitmapData
pub fn data(&self) -> BitmapData
Returns the bitmap’s metadata such as its width and height.
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Gives read acccess to the pixels of the bitmap as an array of bytes.
Each byte represents 8 pixels, where each pixel is a bit. The highest bit is the leftmost
pixel, and lowest bit is the rightmost. There are Bitmap::data().rowbytes many bytes in each
row, regardless of the number of pixels in a row, which can introduce padding bytes between
rows. For this reason, the Bitmap::as_pixels() method is recommended, and easier to use.
Sourcepub fn as_mut_bytes(&mut self) -> &mut [u8]
pub fn as_mut_bytes(&mut self) -> &mut [u8]
Gives read-write acccess to the pixels of the bitmap as an array of bytes.
Each byte represents 8 pixels, where each pixel is a bit. The highest bit is the leftmost
pixel, and lowest bit is the rightmost. There are Bitmap::data().rowbytes many bytes in each
row, regardless of the number of pixels in a row, which can introduce padding bytes between
rows. For this reason, the Bitmap::as_pixels_mit() method is recommended, and easier to use.
Sourcepub fn as_pixels(&self) -> BitmapPixels<'_>
pub fn as_pixels(&self) -> BitmapPixels<'_>
Gives read acccess to the individual pixels of the bitmap.
Sourcepub fn as_pixels_mut(&mut self) -> BitmapPixelsMut<'_>
pub fn as_pixels_mut(&mut self) -> BitmapPixelsMut<'_>
Gives read-write acccess to the individual pixels of the bitmap.
Sourcepub fn clear<'a, C: Into<Color<'a>>>(&mut self, bg_color: C)
pub fn clear<'a, C: Into<Color<'a>>>(&mut self, bg_color: C)
Clears the bitmap, filling with the given bg_color.
Sourcepub fn set_mask_bitmap(&mut self, mask: &BitmapRef) -> Result<(), Error>
pub fn set_mask_bitmap(&mut self, mask: &BitmapRef) -> Result<(), Error>
Sets a mask image for the given bitmap. The set mask must be the same size as the target bitmap.
The mask bitmap is copied, so no reference is held to it. Returns an
Error::DimensionsDoNotMatch if the mask bitmap dimensions do not match with self.
Sourcepub fn mask_bitmap(&self) -> Option<UnownedBitmapMut<'_>>
pub fn mask_bitmap(&self) -> Option<UnownedBitmapMut<'_>>
The mask bitmap attached to this bitmap.
Returns the mask bitmap, if one has been attached with set_mask_bitmap(), or None.