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.
Members
decode_to_widthdecode_to_heightcreate_scaled_bitmapfrom_filefrom_streamfrom_pixelsdisposedpisizepixel_sizesave_to_filesaveformatalpha_formatcopy_pixelscopy_pixels_to_framebuffer
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.
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.
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.
from_file
fn from_file(file_name: &str) -> std::io::Result<Bitmap>
Loads a bitmap from a file.
from_stream
fn from_stream(stream: &mut dyn Read) -> std::io::Result<Bitmap>
Loads a bitmap from a stream.
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.
dispose
fn dispose(self: &Self)
Releases the bitmap's reference to the platform bitmap.
dpi
fn dpi(self: &Self) -> Vector
The dots per inch (DPI) of the image.
size
fn size(self: &Self) -> Size
The size of the image, in device independent pixels.
pixel_size
fn pixel_size(self: &Self) -> PixelSize
The size of the bitmap, in device pixels.
save_to_file
fn save_to_file(self: &Self, file_name: &str, options: &BitmapEncoderOptions) -> std::io::Result<()>
Saves the bitmap to a file.
save
fn save(self: &Self, stream: &mut dyn Write, options: &BitmapEncoderOptions) -> std::io::Result<()>
Saves the bitmap to a stream.
format
fn format(self: &Self) -> Option<PixelFormat>
The pixel format of the bitmap, if its pixels can be read.
alpha_format
fn alpha_format(self: &Self) -> Option<AlphaFormat>
The alpha format of the bitmap, if its pixels can be read.
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.
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeAnyValueClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherIImageIBitmapIImageBrushSourcePartialEqMarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.