pub struct ImageAsset { /* private fields */ }Expand description
static PNG/JPEG/WebP data with EXIF-corrected linear RGBA16F mipmaps. Clones share every level. Encoded profiles are interpreted as sRGB; ICC/HDR profile transforms and animated frame selection belong to later contracts.
Implementations§
Source§impl ImageAsset
impl ImageAsset
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Decodes a bounded static PNG/JPEG/WebP and applies EXIF orientation first.
Sourcepub fn from_rgba8(width: u32, height: u32, pixels: Vec<u8>) -> Result<Self>
pub fn from_rgba8(width: u32, height: u32, pixels: Vec<u8>) -> Result<Self>
Converts straight encoded-sRGB RGBA8 without retaining or decoding it later.
Sourcepub fn from_rgba_float(
width: u32,
height: u32,
pixels: Vec<[f64; 4]>,
) -> Result<Self>
pub fn from_rgba_float( width: u32, height: u32, pixels: Vec<[f64; 4]>, ) -> Result<Self>
Takes straight LINEAR f64 RGBA, then premultiplies and rounds to half. Extended RGB is allowed when premultiplied values fit RGBA16F; alpha must be in 0..=1. Zero or half-rounded-zero alpha clears hidden RGB.
Sourcepub fn levels(&self) -> &[ImageLevel]
pub fn levels(&self) -> &[ImageLevel]
Immutable mip chain, including the base and final 1x1 level.
Sourcepub fn retained_bytes(&self) -> usize
pub fn retained_bytes(&self) -> usize
Logical shared pixel payload, excluding allocation overhead.
Trait Implementations§
Source§impl Asset for ImageAsset
impl Asset for ImageAsset
Source§const KIND: &'static str = "image"
const KIND: &'static str = "image"
Human-readable resource category retained by load diagnostics.
Source§fn decode(bytes: &[u8], _: &LoadContext) -> Result<Self>
fn decode(bytes: &[u8], _: &LoadContext) -> Result<Self>
Decodes bounded input without requiring a rendering device.
Implementations must be deterministic for these bytes/context; recursive
resource dependency graphs are not a supported decoder contract.
Source§fn retained_bytes(&self) -> usize
fn retained_bytes(&self) -> usize
Logical decoded payload charge; custom heap-owning assets should override.
At least the encoded input length is charged regardless of this value.
Source§impl Clone for ImageAsset
impl Clone for ImageAsset
Source§impl Debug for ImageAsset
impl Debug for ImageAsset
Source§impl ImagePixels for ImageAsset
impl ImagePixels for ImageAsset
Source§fn level_count(&self) -> usize
fn level_count(&self) -> usize
Number of immutable mip levels.
Source§fn texel(&self, level: usize, column: usize, row: usize) -> [f32; 4]
fn texel(&self, level: usize, column: usize, row: usize) -> [f32; 4]
One in-bounds finite linear-premultiplied texel.
Source§fn extend_level(&self, level: usize, out: &mut Vec<f32>)
fn extend_level(&self, level: usize, out: &mut Vec<f32>)
Appends every texel of an existing level in row-major order, four
f32 each.
Overriding this avoids one dynamic call per texel for backends that upload whole levels.Source§fn content_eq(&self, other: &dyn ImagePixels) -> bool
fn content_eq(&self, other: &dyn ImagePixels) -> bool
Whether another implementation owns the same immutable pixel content.
Source§impl PartialEq for ImageAsset
impl PartialEq for ImageAsset
impl StructuralPartialEq for ImageAsset
Auto Trait Implementations§
impl Forget for ImageAsset
impl Freeze for ImageAsset
impl Move for ImageAsset
impl RefUnwindSafe for ImageAsset
impl Send for ImageAsset
impl Sync for ImageAsset
impl Unpin for ImageAsset
impl UnsafeUnpin for ImageAsset
impl UnwindSafe for ImageAsset
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
Mutably borrows from an owned value. Read more