pub fn from_unbuffered(
        alpha: &[u8],
        width: usize,
        height: usize,
        buffer: usize,
    ) -> BitmapGlyph {
        assert_eq!(
            alpha.len(),
            width * height,
            "The data length must be equal to width * height."
        );

        let double_buffer = buffer + buffer;

        // Create an larger bitmap that includes a buffer
        let mut buffered_data = vec![0u8; (width + double_buffer) * (height + double_buffer)];

        // Copy the bitmap
        for x in 0..width {
            for y in 0..height {
                buffered_data[(y + buffer) * (width + double_buffer) + x + buffer] =
                    alpha[y * width + x];
            }
        }

        BitmapGlyph {
            alpha: buffered_data,
            width,
            height,
            buffer,
        }
    }
/// Creates a new bitmap from a raw data source, buffered by a given amount.
///
/// Most SDF glyphs are buffered a bit so that the outer edges can be properly captured.
/// This constructor does the buffering for you.
///
/// # Panics
///
/// The caller is responsible for checking the integrity of the data. If the dimensions provided
/// can't describe the input data, this function will panic.
Creates a new bitmap from a raw data source, buffered by a given amount.
Most SDF glyphs are buffered a bit so that the outer edges can be properly captured.
This constructor does the buffering for you.
Creates a new bitmap from a raw data source buffered by a given amount . Most SDF glyphs are buffered a bit so that the outer edges can be properly captured . This constructor does the buffering for you .
pub fn from_unbuffered(
        alpha: &[u8],
        width: usize,
        height: usize,
        buffer: usize,
    ) -> BitmapGlyph {
        assert_eq!(
            alpha.len(),
            width * height,
            "The data length must be equal to width * height."
        );
        let double_buffer = buffer + buffer;
        // Create an larger bitmap that includes a buffer
        let mut buffered_data = vec![0u8; (width + double_buffer) * (height + double_buffer)];
        // Copy the bitmap
        for x in 0..width {
            for y in 0..height {
                buffered_data[(y + buffer) * (width + double_buffer) + x + buffer] =
                    alpha[y * width + x];
            }
        }
        BitmapGlyph {
            alpha: buffered_data,
            width,
            height,
            buffer,
        }
    }
pub fn from_unbuffered ( alpha : & [ u8 ] , width : usize , height : usize , buffer : usize , ) -> BitmapGlyph { assert_eq ! ( alpha len ( ) width height " " ) ; let double_buffer = buffer + buffer ; // Create an larger bitmap that includes a buffer let mut buffered_data = vec ! [ 0u8 ( width double_buffer ) ( height double_buffer ) ] ; // Copy the bitmap for x in 0 .. width { for y in 0 .. height { buffered_data [ ( y + buffer ) * ( width + double_buffer ) + x + buffer ] = alpha [ y * width + x ] ; } } BitmapGlyph { alpha : buffered_data , width , height , buffer , } }
Creates a new bitmap from a raw data source, buffered by a given amount.
Creates a new bitmap from a raw data source buffered by a given amount .
alpha
&[u8]
width
usize
height
usize
buffer
usize
alpha
&[u8]
width
usize
height
usize
buffer
usize
panics
The caller is responsible for checking the integrity of the data. If the dimensions provided
can't describe the input data, this function will panic.
The caller is responsible for checking the integrity of the data . If the dimensions provided can ' t describe the input data this function will panic .