pub struct Bitmap { /* private fields */ }Expand description
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.
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn decode_to_width(
stream: &mut dyn Read,
width: i32,
interpolation_mode: BitmapInterpolationMode,
) -> Result<Bitmap>
pub fn decode_to_width( stream: &mut dyn Read, width: i32, interpolation_mode: BitmapInterpolationMode, ) -> 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.
Sourcepub fn decode_to_height(
stream: &mut dyn Read,
height: i32,
interpolation_mode: BitmapInterpolationMode,
) -> Result<Bitmap>
pub fn decode_to_height( stream: &mut dyn Read, height: i32, interpolation_mode: BitmapInterpolationMode, ) -> Result<Bitmap>
Loads a bitmap from a stream, decoded to the specified height maintaining aspect ratio.
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 from_stream(stream: &mut dyn Read) -> Result<Bitmap>
pub fn from_stream(stream: &mut dyn Read) -> Result<Bitmap>
Loads a bitmap from a stream.
Sourcepub fn from_ref(platform_impl: &RefCounted<SharedBitmapImpl>) -> Bitmap
pub fn from_ref(platform_impl: &RefCounted<SharedBitmapImpl>) -> Bitmap
Creates a bitmap sharing a platform bitmap: takes another reference to it.
Sourcepub fn from_impl(platform_impl: Arc<SharedBitmapImpl>) -> Bitmap
pub fn from_impl(platform_impl: Arc<SharedBitmapImpl>) -> Bitmap
Creates a bitmap owning a platform bitmap.
Sourcepub fn from_pixels(
format: PixelFormat,
alpha_format: AlphaFormat,
data: &[u8],
size: PixelSize,
dpi: Vector,
stride: i32,
) -> Bitmap
pub 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.
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 IBitmap for Bitmap
impl IBitmap for Bitmap
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 Bitmap
impl IImage for Bitmap
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 Bitmap
impl IImageBrushSource for Bitmap
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>>
Source§impl MarkupTyped for Bitmap
impl MarkupTyped for Bitmap
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Auto Trait Implementations§
impl !Freeze for Bitmap
impl RefUnwindSafe for Bitmap
impl Send for Bitmap
impl Sync for Bitmap
impl Unpin for Bitmap
impl UnsafeUnpin for Bitmap
impl UnwindSafe for Bitmap
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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