WriteableBitmap
struct · ferroui-base · v0.5.0
struct WriteableBitmap
Holds a writeable bitmap image.
Members
new
fn new(size: PixelSize, dpi: Vector, format: Option<PixelFormat>, alpha_format: Option<AlphaFormat>) -> WriteableBitmap
Creates a bitmap of the given size, in pixels, and DPI. The formats default to the backend's default formats.
Panics when the size is not positive or the pixel format is not supported.
from_pixels
fn from_pixels(format: PixelFormat, alpha_format: AlphaFormat, data: &[u8], size: PixelSize, dpi: Vector, stride: i32) -> WriteableBitmap
Creates a writeable bitmap from a pixel data copy: data holds rows
of format pixels, stride bytes apart.
Panics when stride is too small for a row.
format
fn format(self: &Self) -> Option<PixelFormat>
The pixel format of the bitmap.
lock
fn lock(self: &Self) -> Rc<dyn ILockedFramebuffer>
Locks the pixel data of the bitmap and returns a framebuffer that can be used to read and write the pixels. The changes are committed when the framebuffer is disposed.
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.
decode
fn decode(stream: &mut dyn Read) -> std::io::Result<WriteableBitmap>
Loads a writeable bitmap from a stream.
decode_to_width
fn decode_to_width(stream: &mut dyn Read, width: i32, interpolation_mode: BitmapInterpolationMode) -> std::io::Result<WriteableBitmap>
Loads a writeable bitmap from a stream, decoded to the specified width maintaining aspect ratio.
decode_to_height
fn decode_to_height(stream: &mut dyn Read, height: i32, interpolation_mode: BitmapInterpolationMode) -> std::io::Result<WriteableBitmap>
Loads a writeable bitmap from a stream, decoded to the specified height maintaining aspect ratio.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyErasedDestructorIntoEitherDerefIImageIBitmapIImageBrushSource
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.