FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Bitmap

    struct · ferroui-base · v0.5.0

    struct Bitmap
    

    Holds a bitmap image.

    The types deriving from it (WriteableBitmap, RenderTargetBitmap) dereference to Bitmap; the members they override are reached through the deriving type or through IBitmap/IImage handles.

    View source

    Members

    decode_to_width

    fn decode_to_width(stream: &mut dyn Read, width: i32, interpolation_mode: BitmapInterpolationMode) -> std::io::Result<Bitmap>
    

    Loads a bitmap from a stream, decoded to the specified width maintaining aspect ratio.

    interpolation_mode is used should a resize be necessary; upstream defaults it to high quality.

    Source

    decode_to_height

    fn decode_to_height(stream: &mut dyn Read, height: i32, interpolation_mode: BitmapInterpolationMode) -> std::io::Result<Bitmap>
    

    Loads a bitmap from a stream, decoded to the specified height maintaining aspect ratio.

    Source

    create_scaled_bitmap

    fn create_scaled_bitmap(self: &Self, destination_size: PixelSize, interpolation_mode: BitmapInterpolationMode) -> Bitmap
    

    Creates a bitmap scaled to the specified size from the current bitmap.

    Source

    from_file

    fn from_file(file_name: &str) -> std::io::Result<Bitmap>
    

    Loads a bitmap from a file.

    Source

    from_stream

    fn from_stream(stream: &mut dyn Read) -> std::io::Result<Bitmap>
    

    Loads a bitmap from a stream.

    Source

    from_pixels

    fn from_pixels(format: PixelFormat, alpha_format: AlphaFormat, data: &[u8], size: PixelSize, dpi: Vector, stride: i32) -> Bitmap
    

    Creates a bitmap from pixel data: stride * size.height bytes of format/alpha_format pixels.

    A format the backend cannot hold is converted to RGBA8888.

    Source

    dispose

    fn dispose(self: &Self)
    

    Releases the bitmap's reference to the platform bitmap.

    Source

    dpi

    fn dpi(self: &Self) -> Vector
    

    The dots per inch (DPI) of the image.

    Source

    size

    fn size(self: &Self) -> Size
    

    The size of the image, in device independent pixels.

    Source

    pixel_size

    fn pixel_size(self: &Self) -> PixelSize
    

    The size of the bitmap, in device pixels.

    Source

    save_to_file

    fn save_to_file(self: &Self, file_name: &str, options: &BitmapEncoderOptions) -> std::io::Result<()>
    

    Saves the bitmap to a file.

    Source

    save

    fn save(self: &Self, stream: &mut dyn Write, options: &BitmapEncoderOptions) -> std::io::Result<()>
    

    Saves the bitmap to a stream.

    Source

    format

    fn format(self: &Self) -> Option<PixelFormat>
    

    The pixel format of the bitmap, if its pixels can be read.

    Source

    alpha_format

    fn alpha_format(self: &Self) -> Option<AlphaFormat>
    

    The alpha format of the bitmap, if its pixels can be read.

    Source

    copy_pixels

    fn copy_pixels(self: &Self, source_rect: PixelRect, buffer: &mut [u8], stride: i32)
    

    Copies the pixels of source_rect into buffer, whose rows are stride bytes apart. An empty source_rect selects the whole bitmap.

    Panics when the pixels of the bitmap cannot be read, when the bitmap was converted from another pixel format on creation, or when the rectangle, stride or buffer are out of range.

    Source

    copy_pixels_to_framebuffer

    fn copy_pixels_to_framebuffer(self: &Self, buffer: &dyn ILockedFramebuffer)
    

    Copies the pixels of the bitmap into a locked framebuffer, converting them to its pixel and alpha formats.

    Panics when the pixels of the bitmap cannot be read.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.