pub struct ImageBitmap { /* private fields */ }Expand description
Immutable image data used by UI primitives and render backends.
Implementations§
Source§impl ImageBitmap
impl ImageBitmap
Sourcepub fn from_rgba8(
width: u32,
height: u32,
pixels: Vec<u8>,
) -> Result<Self, ImageBitmapError>
pub fn from_rgba8( width: u32, height: u32, pixels: Vec<u8>, ) -> Result<Self, ImageBitmapError>
Creates a bitmap by taking ownership of tightly packed RGBA8 pixels. Any spare capacity in the pixel buffer is released.
Sourcepub fn from_rgba8_slice(
width: u32,
height: u32,
pixels: &[u8],
) -> Result<Self, ImageBitmapError>
pub fn from_rgba8_slice( width: u32, height: u32, pixels: &[u8], ) -> Result<Self, ImageBitmapError>
Copies tightly packed RGBA8 pixels into a new bitmap.
Sourcepub fn from_alpha8(
width: u32,
height: u32,
color: [u8; 3],
alpha: Vec<u8>,
) -> Result<Self, ImageBitmapError>
pub fn from_alpha8( width: u32, height: u32, color: [u8; 3], alpha: Vec<u8>, ) -> Result<Self, ImageBitmapError>
Takes ownership of one alpha byte per pixel with a constant RGB color. Any spare capacity in the alpha buffer is released.
Sourcepub fn id(&self) -> u64
pub fn id(&self) -> u64
Content-derived bitmap identity used by renderer caches. Each frame
of an ExternalTexture has its own id.
Sourcepub fn storage_id(&self) -> u64
pub fn storage_id(&self) -> u64
Identity of the bitmap’s storage: the same for every frame of an
ExternalTexture, equal to Self::id for pixel bitmaps.
Sourcepub fn external_handle<T: 'static>(&self) -> Option<&T>
pub fn external_handle<T: 'static>(&self) -> Option<&T>
The renderer handle of an ExternalTexture frame, when it is a T.
Sourcepub fn pixels(&self) -> &[u8] ⓘ
pub fn pixels(&self) -> &[u8] ⓘ
Returns the raw pixel bytes in Self::format, empty for an
ExternalTexture frame.
Sourcepub fn format(&self) -> ImagePixelFormat
pub fn format(&self) -> ImagePixelFormat
Returns the storage format of Self::pixels.
Sourcepub fn rgba8_pixel(&self, index: usize) -> [u8; 4]
pub fn rgba8_pixel(&self, index: usize) -> [u8; 4]
Returns the unpremultiplied RGBA8 pixel at a row-major index;
transparent for an ExternalTexture frame.
§Panics
Panics when index is outside the image.
Sourcepub fn rgba8_pixels(&self) -> Cow<'_, [u8]>
pub fn rgba8_pixels(&self) -> Cow<'_, [u8]>
Returns tightly packed RGBA8 bytes, borrowing RGBA images and expanding
alpha masks; empty for an ExternalTexture frame.
Sourcepub fn intrinsic_size(&self) -> Size
pub fn intrinsic_size(&self) -> Size
Returns intrinsic size in logical units.