pub struct Img { /* private fields */ }Expand description
State of an ImageVar.
Each instance of this struct represent a single state,
Implementations§
Source§impl Img
impl Img
Sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns true if the is still acquiring or decoding the image bytes.
Sourcepub fn wait_done(&self) -> impl Future<Output = ()> + Send + Sync + 'static
pub fn wait_done(&self) -> impl Future<Output = ()> + Send + Sync + 'static
Returns a future that awaits until this image is loaded or encountered an error.
Sourcepub fn density(&self) -> Option<PxDensity2d>
pub fn density(&self) -> Option<PxDensity2d>
Returns the image pixel density metadata if the image is loaded and the metadata was retrieved.
Sourcepub fn layout_size(&self, ctx: &LayoutMetrics) -> PxSize
pub fn layout_size(&self, ctx: &LayoutMetrics) -> PxSize
Calculate an ideal layout size for the image.
The image is scaled considering the density and screen scale factor. If the
image has no density falls back to the screen_density in both dimensions.
Sourcepub fn calc_size(
&self,
ctx: &LayoutMetrics,
fallback_density: PxDensity2d,
ignore_image_density: bool,
) -> PxSize
pub fn calc_size( &self, ctx: &LayoutMetrics, fallback_density: PxDensity2d, ignore_image_density: bool, ) -> PxSize
Sourcepub fn pixels(&self) -> Option<IpcBytes>
pub fn pixels(&self) -> Option<IpcBytes>
Reference the decoded pre-multiplied BGRA8 pixel buffer or A8 if is_mask.
Sourcepub fn copy_pixels(&self, rect: PxRect) -> Option<(PxRect, Vec<u8>)>
pub fn copy_pixels(&self, rect: PxRect) -> Option<(PxRect, Vec<u8>)>
Copy the rect selection from pixels.
The rect is in pixels, with the origin (0, 0) at the top-left of the image.
Returns the copied selection and the pixel buffer.
Note that the selection can change if rect is not fully contained by the image area.
Sourcepub async fn encode(&self, format: Txt) -> Result<IpcBytes, EncodeError>
pub async fn encode(&self, format: Txt) -> Result<IpcBytes, EncodeError>
Encode the image to the format.
Trait Implementations§
Source§impl Img for Img
impl Img for Img
Source§fn renderer_id(&self, renderer: &ViewRenderer) -> ImageTextureId
fn renderer_id(&self, renderer: &ViewRenderer) -> ImageTextureId
renderer namespace. Read moreSource§fn alpha_type(&self) -> AlphaType
fn alpha_type(&self) -> AlphaType
Auto Trait Implementations§
impl !Freeze for Img
impl !RefUnwindSafe for Img
impl Send for Img
impl Sync for Img
impl Unpin for Img
impl !UnwindSafe for Img
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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