pub struct WriteableBitmap { /* private fields */ }Expand description
Holds a writeable bitmap image.
Implementations§
Source§impl WriteableBitmap
impl WriteableBitmap
Sourcepub fn new(
size: PixelSize,
dpi: Vector,
format: Option<PixelFormat>,
alpha_format: Option<AlphaFormat>,
) -> WriteableBitmap
pub 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.
Sourcepub fn from_pixels(
format: PixelFormat,
alpha_format: AlphaFormat,
data: &[u8],
size: PixelSize,
dpi: Vector,
stride: i32,
) -> WriteableBitmap
pub 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.
Sourcepub fn format(&self) -> Option<PixelFormat>
pub fn format(&self) -> Option<PixelFormat>
The pixel format of the bitmap.
Sourcepub fn lock(&self) -> Rc<dyn ILockedFramebuffer>
pub fn lock(&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.
Sourcepub fn copy_pixels(
&self,
source_rect: PixelRect,
buffer: &mut [u8],
stride: i32,
)
pub fn copy_pixels( &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.
Sourcepub fn decode(stream: &mut dyn Read) -> Result<WriteableBitmap>
pub fn decode(stream: &mut dyn Read) -> Result<WriteableBitmap>
Loads a writeable bitmap from a stream.
Sourcepub fn decode_to_width(
stream: &mut dyn Read,
width: i32,
interpolation_mode: BitmapInterpolationMode,
) -> Result<WriteableBitmap>
pub fn decode_to_width( stream: &mut dyn Read, width: i32, interpolation_mode: BitmapInterpolationMode, ) -> Result<WriteableBitmap>
Loads a writeable bitmap from a stream, decoded to the specified width maintaining aspect ratio.
Sourcepub fn decode_to_height(
stream: &mut dyn Read,
height: i32,
interpolation_mode: BitmapInterpolationMode,
) -> Result<WriteableBitmap>
pub fn decode_to_height( stream: &mut dyn Read, height: i32, interpolation_mode: BitmapInterpolationMode, ) -> Result<WriteableBitmap>
Loads a writeable bitmap from a stream, decoded to the specified height maintaining aspect ratio.
Methods from Deref<Target = Bitmap>§
Sourcepub fn create_scaled_bitmap(
&self,
destination_size: PixelSize,
interpolation_mode: BitmapInterpolationMode,
) -> Bitmap
pub fn create_scaled_bitmap( &self, destination_size: PixelSize, interpolation_mode: BitmapInterpolationMode, ) -> Bitmap
Creates a bitmap scaled to the specified size from the current bitmap.
Sourcepub fn pixel_size(&self) -> PixelSize
pub fn pixel_size(&self) -> PixelSize
The size of the bitmap, in device pixels.
Sourcepub fn platform_impl(&self) -> &RefCounted<SharedBitmapImpl>
pub fn platform_impl(&self) -> &RefCounted<SharedBitmapImpl>
The platform-specific bitmap implementation.
Sourcepub fn save_to_file(
&self,
file_name: &str,
options: &BitmapEncoderOptions,
) -> Result<()>
pub fn save_to_file( &self, file_name: &str, options: &BitmapEncoderOptions, ) -> Result<()>
Saves the bitmap to a file.
Sourcepub fn save(
&self,
stream: &mut dyn Write,
options: &BitmapEncoderOptions,
) -> Result<()>
pub fn save( &self, stream: &mut dyn Write, options: &BitmapEncoderOptions, ) -> Result<()>
Saves the bitmap to a stream.
Sourcepub fn format(&self) -> Option<PixelFormat>
pub fn format(&self) -> Option<PixelFormat>
The pixel format of the bitmap, if its pixels can be read.
Sourcepub fn alpha_format(&self) -> Option<AlphaFormat>
pub fn alpha_format(&self) -> Option<AlphaFormat>
The alpha format of the bitmap, if its pixels can be read.
Sourcepub fn copy_pixels(
&self,
source_rect: PixelRect,
buffer: &mut [u8],
stride: i32,
)
pub fn copy_pixels( &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.
Sourcepub fn copy_pixels_to_framebuffer(&self, buffer: &dyn ILockedFramebuffer)
pub fn copy_pixels_to_framebuffer(&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§
Source§impl Deref for WriteableBitmap
impl Deref for WriteableBitmap
Source§impl IBitmap for WriteableBitmap
impl IBitmap for WriteableBitmap
Source§fn pixel_size(&self) -> PixelSize
fn pixel_size(&self) -> PixelSize
Source§fn platform_impl(&self) -> &RefCounted<SharedBitmapImpl>
fn platform_impl(&self) -> &RefCounted<SharedBitmapImpl>
Source§impl IImage for WriteableBitmap
impl IImage for WriteableBitmap
Source§fn draw(
&self,
context: &mut DrawingContext<'_>,
source_rect: Rect,
dest_rect: Rect,
)
fn draw( &self, context: &mut DrawingContext<'_>, source_rect: Rect, dest_rect: Rect, )
source_rect is drawn into dest_rect.Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
as_object.Source§fn as_object(&self) -> Option<&FerroObject>
fn as_object(&self) -> Option<&FerroObject>
Source§fn as_affects_render(&self) -> Option<&dyn IAffectsRender>
fn as_affects_render(&self) -> Option<&dyn IAffectsRender>
IAffectsRender, when it can change.Source§impl IImageBrushSource for WriteableBitmap
impl IImageBrushSource for WriteableBitmap
Source§fn bitmap(&self) -> Option<&RefCounted<SharedBitmapImpl>>
fn bitmap(&self) -> Option<&RefCounted<SharedBitmapImpl>>
Source§fn get_bitmap(&self) -> Option<Arc<SharedBitmapImpl>>
fn get_bitmap(&self) -> Option<Arc<SharedBitmapImpl>>
Auto Trait Implementations§
impl !Freeze for WriteableBitmap
impl !RefUnwindSafe for WriteableBitmap
impl !Send for WriteableBitmap
impl !Sync for WriteableBitmap
impl !UnwindSafe for WriteableBitmap
impl Unpin for WriteableBitmap
impl UnsafeUnpin for WriteableBitmap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more