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 size(&self) -> Size2D<Px, Px>
pub fn size(&self) -> Size2D<Px, Px>
Returns the image size in pixels, or zero if it is not loaded.
sourcepub fn ppi(&self) -> Option<ImagePpi>
pub fn ppi(&self) -> Option<ImagePpi>
Returns the image pixel-per-inch metadata if the image is loaded and the metadata was retrieved.
sourcepub fn layout_size(&self, ctx: &LayoutMetrics) -> Size2D<Px, Px>
pub fn layout_size(&self, ctx: &LayoutMetrics) -> Size2D<Px, Px>
Calculate an ideal layout size for the image.
The image is scaled considering the ppi
and screen scale factor. If the
image has no ppi
falls back to the screen_ppi
in both dimensions.
sourcepub fn calc_size(
&self,
ctx: &LayoutMetrics,
fallback_ppi: ImagePpi,
ignore_image_ppi: bool,
) -> Size2D<Px, Px>
pub fn calc_size( &self, ctx: &LayoutMetrics, fallback_ppi: ImagePpi, ignore_image_ppi: bool, ) -> Size2D<Px, Px>
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: Rect<Px, Px>) -> Option<(Rect<Px, Px>, Vec<u8>)>
pub fn copy_pixels(&self, rect: Rect<Px, Px>) -> Option<(Rect<Px, Px>, 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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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