Struct theme_parser::render::pff2::Bitmap
source · pub struct Bitmap { /* private fields */ }
Expand description
A bitmap that can be used to query pixel data in a PFF2 Glyph.
There are 2 ways of querying pixels:
- Using
Self::pixel()
let bitmap = Bitmap::new(8, 1, &[0b00000001])?;
let pixel = bitmap.pixel(7, 0)?;
assert_eq!(pixel, true);
- Using an iterator
let bitmap = Bitmap::default();
for row in bitmap {
for pixel in row {
print!("{}", if pixel { "##" } else { " " });
}
}
Implementations§
source§impl Bitmap
impl Bitmap
sourcepub fn byte_count_from_size(width: usize, height: usize) -> usize
pub fn byte_count_from_size(width: usize, height: usize) -> usize
Calculates the length of the bitmap in bytes from the dimentions of the bitmap in pixels
sourcepub fn new(width: usize, height: usize, bitmap: &[u8]) -> Option<Self>
pub fn new(width: usize, height: usize, bitmap: &[u8]) -> Option<Self>
Constructs self by wrapping the bitmap slice in a OwnedSlice
and verifying that it’s length is exactly
Self::byte_count_from_size
.
sourcepub fn pixel(&self, x: usize, y: usize) -> Option<bool>
pub fn pixel(&self, x: usize, y: usize) -> Option<bool>
Returns Some(true)
if the pixel is filled, Some(false)
if the pixel if transparent, None
if out of
bounds.
sourcepub fn iter(&self) -> BitmapIter ⓘ
pub fn iter(&self) -> BitmapIter ⓘ
Creates an iter over self
Trait Implementations§
source§impl IntoIterator for &Bitmap
impl IntoIterator for &Bitmap
source§impl IntoIterator for Bitmap
impl IntoIterator for Bitmap
source§impl PartialEq for Bitmap
impl PartialEq for Bitmap
impl Eq for Bitmap
impl StructuralEq for Bitmap
impl StructuralPartialEq for Bitmap
Auto Trait Implementations§
impl RefUnwindSafe for Bitmap
impl !Send for Bitmap
impl !Sync for Bitmap
impl Unpin for Bitmap
impl UnwindSafe for Bitmap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more