pub struct Bitmap(/* private fields */);Expand description
Raster images from bytes (docs/images.md): decode an encoded PNG or JPEG the app already
holds (a download, a file the user picked, a paste) into the platform’s image type, then
show it with image(&bitmap) or draw it with Draw::image.
Bitmap is a handle, not the pixels: they live in the toolkit and are released when the last
handle drops. Decoding is asynchronous because several backends decode off the main thread.
Probe image_decode_support() / image_encode_support() before offering an affordance that
depends on either, and image_encode_formats() before offering a format, since every
platform here reads more formats than it writes.
A decoded image the toolkit holds, released when the last handle drops.
Cheap to clone (an Rc), so several nodes and the canvas can draw the same decode. !Send
like everything else that talks to the toolkit.
Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn id(&self) -> BitmapId
pub fn id(&self) -> BitmapId
The id the toolkit knows this image by, which day_spec::ImageSource::Decoded carries.
Sourcepub fn info(&self) -> BitmapInfo
pub fn info(&self) -> BitmapInfo
Pixel size, scale, format and alpha, read once at decode (docs/images.md).
Sourcepub fn properties(&self) -> Option<ImageProperties>
pub fn properties(&self) -> Option<ImageProperties>
The metadata beyond the pixels: EXIF orientation, DPI, capture time. None where this
backend ships no metadata reader; probe Cap::ImageProperties before offering an
affordance that needs it.
Sourcepub fn encode(&self, spec: EncodeSpec) -> EncodeFuture ⓘ
pub fn encode(&self, spec: EncodeSpec) -> EncodeFuture ⓘ
Encode back to bytes, in spec’s format. Await it inside day::task.
Sourcepub fn encode_async(
&self,
spec: EncodeSpec,
on_done: impl FnOnce(Result<Vec<u8>, ImageError>) + 'static,
)
pub fn encode_async( &self, spec: EncodeSpec, on_done: impl FnOnce(Result<Vec<u8>, ImageError>) + 'static, )
Bitmap::encode’s callback half, for a call site that is not already async.
Trait Implementations§
Source§impl IntoImageSource<ImageValueMark> for &Bitmap
A decoded image draws by id, so several nodes (and the canvas) share one decode.
A decoded handle. The piece keeps a clone alive for the node’s life: the closure below owns
it, the binding owns the closure, and the node’s scope owns the binding, so the toolkit’s
image outlives the view that shows it however the app juggles its own handle. Without this an
image(&bitmap) would carry only the id, and on the web the <img> would point at an object
URL that release_image had already revoked.
impl IntoImageSource<ImageValueMark> for &Bitmap
A decoded image draws by id, so several nodes (and the canvas) share one decode.
A decoded handle. The piece keeps a clone alive for the node’s life: the closure below owns
it, the binding owns the closure, and the node’s scope owns the binding, so the toolkit’s
image outlives the view that shows it however the app juggles its own handle. Without this an
image(&bitmap) would carry only the id, and on the web the <img> would point at an object
URL that release_image had already revoked.
fn into_image_source(self) -> Reactive<ImageSource>
Auto Trait Implementations§
impl !Send for Bitmap
impl !Sync for Bitmap
impl Freeze for Bitmap
impl RefUnwindSafe for Bitmap
impl Unpin for Bitmap
impl UnsafeUnpin for Bitmap
impl UnwindSafe for Bitmap
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> ErasedDestructor for Twhere
T: 'static,
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