Skip to main content

ImmutableBitmap

Struct ImmutableBitmap 

Source
pub struct ImmutableBitmap { /* private fields */ }
Expand description

Immutable bitmap: pixels that never change.

The bitmap is drawn from an image of premultiplied RGBA pixels, the one format the renderers draw. A bitmap that was created from pixels in another format keeps those as well: it reports their format and is read in it, as a bitmap of the Skia backend, which draws every format it has a color type for.

Implementations§

Source§

impl ImmutableBitmap

Source

pub fn from_image(image: ImageData) -> Self

Wraps an image of premultiplied RGBA pixels.

Source

pub fn from_stream(stream: &mut dyn Read) -> Result<Self>

Creates an immutable bitmap from the given stream.

Source

pub fn from_stream_to_size( stream: &mut dyn Read, decode_size: i32, horizontal: bool, interpolation_mode: BitmapInterpolationMode, ) -> Result<Self>

Creates an immutable bitmap from a stream, decoded so that its width (horizontal) or height is decode_size.

Source

pub fn resized( src: &ImmutableBitmap, destination_size: PixelSize, interpolation_mode: BitmapInterpolationMode, ) -> Result<Self>

Creates a resized copy of src.

Source

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

Creates an immutable bitmap from raw pixel data, which is copied.

data holds |stride| * size.height bytes. A negative stride means the rows are stored bottom-up: the first row of the image is the last row of data.

§Panics

Panics when the pixel format is unknown to the backend.

Trait Implementations§

Source§

impl IBitmapImpl for ImmutableBitmap

Source§

fn dpi(&self) -> Vector

The dots per inch (DPI) of the image.
Source§

fn pixel_size(&self) -> PixelSize

The size of the bitmap, in device pixels.
Source§

fn version(&self) -> i32

Version of the pixel data: incremented whenever the content changes.
Source§

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

Saves the bitmap to a stream, encoded as selected by options.
Source§

fn dispose(&self)

Releases the bitmap’s resources.
Source§

fn as_any(&self) -> &dyn Any

Lets the backend recover its concrete type.
Source§

fn as_readable_bitmap(&self) -> Option<&dyn IReadableBitmapImpl>

The bitmap viewed as IReadableBitmapImpl, when its pixels can be read.
Source§

impl IDrawableBitmapImpl for ImmutableBitmap

Source§

fn image(&self) -> Option<ImageData>

The current pixels of the bitmap as an image of premultiplied RGBA pixels, or None once the bitmap is disposed. The image is kept until the pixels change: drawing a bitmap again copies nothing.
Source§

impl IReadableBitmapImpl for ImmutableBitmap

Source§

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

The pixel format, if known.
Source§

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

The alpha format, if known.
Source§

fn lock(&self) -> Rc<dyn ILockedFramebuffer>

Locks the pixels for reading (and writing, for writeable bitmaps).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,