Allow to load an image from memory

New `image::Handle` opaque type uniquely identifying some `image::Data`,
allowing reliable caching.
This commit is contained in:
Héctor Ramón Jiménez 2019-11-29 21:44:39 +01:00
parent 811d8b90d7
commit 505588d585
5 changed files with 133 additions and 33 deletions

View file

@ -2,14 +2,18 @@ use crate::{Primitive, Renderer};
use iced_native::{image, Layout, MouseCursor};
impl image::Renderer for Renderer {
fn dimensions(&self, path: &str) -> (u32, u32) {
self.image_pipeline.dimensions(path)
fn dimensions(&self, handle: &image::Handle) -> (u32, u32) {
self.image_pipeline.dimensions(handle)
}
fn draw(&mut self, path: &str, layout: Layout<'_>) -> Self::Output {
fn draw(
&mut self,
handle: image::Handle,
layout: Layout<'_>,
) -> Self::Output {
(
Primitive::Image {
path: String::from(path),
handle,
bounds: layout.bounds(),
},
MouseCursor::OutOfBounds,