pub struct Bitmap {
pub width: u32,
pub height: u32,
pub pixels: Vec<u8>,
}Expand description
A greyscale glyph bitmap.
Fields§
§width: u32Width in pixels.
height: u32Height in pixels.
pixels: Vec<u8>Pixel data, one byte per pixel (0 = transparent, 255 = fully opaque).
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the bitmap has zero area (no visible pixels), as is
the case for whitespace glyphs.
Sourcepub fn invert_coverage(&self) -> Self
pub fn invert_coverage(&self) -> Self
Invert the coverage values (255 - x) for use in inside/outside SDF generation.
Coverage bitmaps from rasterizers use 255 = opaque, 0 = transparent. Some SDF algorithms expect the inverse convention where 0 = inside the glyph outline. This method produces a new bitmap with all values flipped.
Sourcepub fn threshold(&self, threshold: u8) -> Self
pub fn threshold(&self, threshold: u8) -> Self
Return a copy with pixels below the threshold set to 0, above (or equal) to 255.
Useful for binarizing a greyscale coverage map before Euclidean Distance Transform (EDT) so that only fully-inside and fully-outside pixels are distinguished.