pub struct Bitmap { /* private fields */ }Expand description
A rectangular 2d-array of u8 where the values 0 through 255 represent shades of grey.
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn lines(&self) -> Chunks<'_, u8>
pub fn lines(&self) -> Chunks<'_, u8>
Return an iterator over the lines of the bitmap going from top to bottom.
Examples found in repository?
examples/basic_char.rs (line 8)
4fn main() {
5 let bytes = include_bytes!("Gudea-Regular.ttf");
6 let font = load_font_from_bytes(bytes.to_vec());
7 let (_, bitmap) = font.render_char('A', 40.0).unwrap();
8 for line in bitmap.lines() {
9 for &pixel in line {
10 if pixel == 0 {
11 print!(" ");
12 } else {
13 print!("#");
14 }
15 }
16 println!("");
17 }
18}More examples
examples/basic_atlas.rs (line 9)
4fn main() {
5 let bytes = include_bytes!("Gudea-Regular.ttf");
6 let font = load_font_from_bytes(bytes.to_vec());
7 let chars = font_atlas::ASCII.iter().cloned().chain(font_atlas::ASCII.iter().cloned());
8 let (_, bitmap, _) = font.make_atlas(chars, 20.0, 1, 128, 128);
9 for line in bitmap.lines() {
10 print!("{:03} ", line.len());
11 for &pixel in line {
12 if pixel == 0 {
13 print!(" ");
14 } else {
15 print!("#");
16 }
17 }
18 println!("");
19 }
20}Trait Implementations§
Source§impl Buffer2d for Bitmap
impl Buffer2d for Bitmap
type Pixel = u8
fn width(&self) -> u32
fn height(&self) -> u32
fn get(&self, x: u32, y: u32) -> Option<Self::Pixel>
fn set(&mut self, x: u32, y: u32, val: Self::Pixel)
fn patch<B: Buffer2d<Pixel = Self::Pixel>>(&mut self, x: u32, y: u32, buf: &B)
fn patch_rotated<B: Buffer2d<Pixel = Self::Pixel>>( &mut self, x: u32, y: u32, buf: &B, )
fn dimensions(&self) -> (u32, u32)
Auto Trait Implementations§
impl Freeze for Bitmap
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