pub trait HardwareImageCodecs {
// Required methods
fn decode(
&self,
image: &dyn ImageSource,
index: u32,
max_size: Option<Size>,
) -> ImageFuture<Arc<dyn HardwareBuffer>>;
fn encode(
&self,
buffer: &dyn HardwareBuffer,
format: &str,
quality: Option<f32>,
) -> ImageFuture<Vec<u8>>;
}Expand description
The system’s codecs between encoded images and hardware buffers, with no copy through the
app’s memory, or None from ImageCodecs::hardware_image_codecs where it has none.
Required Methods§
Sourcefn decode(
&self,
image: &dyn ImageSource,
index: u32,
max_size: Option<Size>,
) -> ImageFuture<Arc<dyn HardwareBuffer>>
fn decode( &self, image: &dyn ImageSource, index: u32, max_size: Option<Size>, ) -> ImageFuture<Arc<dyn HardwareBuffer>>
Picture index of image, as ImageSource::decode_pixels names it, in a hardware buffer
of the app’s own, for sampling, upright, scaled down to fit max_size, in pixels, keeping
its shape, where given:
ImageErrorKind::TooLarge where it is larger than a hardware buffer the system makes. An
image another host opened fails, as ImageErrorKind::Unsupported.
Sourcefn encode(
&self,
buffer: &dyn HardwareBuffer,
format: &str,
quality: Option<f32>,
) -> ImageFuture<Vec<u8>>
fn encode( &self, buffer: &dyn HardwareBuffer, format: &str, quality: Option<f32>, ) -> ImageFuture<Vec<u8>>
buffer‘s pixels encoded in format, one of the image codecs’
encoded_formats, at quality as
ImageCodecs::encode_pixels takes it, reading what the GPU has finished writing, as
HardwareBuffer::read_pixels does: ImageErrorKind::Unsupported for a format it does
not encode, or a buffer whose pixels it does not read, such as one another host handed out.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".