pub struct CpuImage { /* private fields */ }Expand description
A picture the CPU renderer drew or was lent: premultiplied, sRGB-encoded RGBA, as every GPU intermediate texture holds it.
Only its content rectangle is stored; every pixel outside it is transparent. A label on a 1080p canvas keeps the label’s pixels, not the canvas’s.
Implementations§
Source§impl CpuImage
impl CpuImage
Sourcepub fn from_premultiplied_rgba8(
size: RenderSize,
rgba8: &[u8],
) -> Result<Self, RenderError>
pub fn from_premultiplied_rgba8( size: RenderSize, rgba8: &[u8], ) -> Result<Self, RenderError>
Premultiplied, sRGB-encoded RGBA8 pixels, rows packed, as
crate::Renderer::upload_rgba8 takes them: a picture sampled as
that texture is.
§Errors
Returns RenderError::InvalidImageData when rgba8 does not hold
four bytes per pixel of size.
Sourcepub const fn size(&self) -> RenderSize
pub const fn size(&self) -> RenderSize
The picture’s dimensions.
Sourcepub fn retained_bytes(&self) -> u64
pub fn retained_bytes(&self) -> u64
Bytes the picture holds.
Sourcepub fn read_rgba8(&self) -> Vec<u8> ⓘ
pub fn read_rgba8(&self) -> Vec<u8> ⓘ
The picture as tightly packed RGBA8, as crate::Renderer::read_rgba8
reads a texture back: each component rounded to the nearest code.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CpuImage
impl RefUnwindSafe for CpuImage
impl Send for CpuImage
impl Sync for CpuImage
impl Unpin for CpuImage
impl UnsafeUnpin for CpuImage
impl UnwindSafe for CpuImage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more