-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load images from memory and image viewer example #90
Conversation
New `image::Handle` opaque type uniquely identifying some `image::Data`, allowing reliable caching.
If you're interested, I'd be glad to write a version of this that directly accepts an image-rs image. |
One of the main focus of Iced is simplicity and I think the Additionally, we have to consider that this is a dependency of a specific renderer (which turns out to be the default) and Iced also supports the For now, I'd like to gather use cases and keep things simple. |
That's a reasonable approach. There is one suggestion I have if you're planning to keep this API: right now Alternately, Image-rs's equivalent method is called |
@ejmahler I think we could call it However, we cannot return a For now, an It's true that, in this case, |
I was able to get iced working, and I made a proof of concept of this feature. check it out if you're curious: https://github.com/ejmahler/SandpileFractal You can see the actual rendering code where it converts an image buffer to an image handle here: https://github.com/ejmahler/SandpileFractal/blob/master/src/render.rs#L71 In this particular case, it would be more convenient to pass the uncompressed RGB data directly through to iced, but it doesn't look like it has any kind of performance impact. Or if there is one, it hidden by the fact that the work is being done in a background thread, so the UI keeps feeling responsive. |
@ejmahler Amazing! |
@ejmahler That's awesome! I wonder if writing the image using BMP format would speed things up. I guess we can avoid implementing pixmap methods for the time being, as advanced users like you can leverage the I don't think we should focus too much on performance yet, so I am okay with this for now. |
Also, replace `image` example with a new `pokedex` example using the PokéAPI.
Closes #76.
This PR implements an
image::Handle
type which allows displaying images from data living in-memory and from the filesystem as well. Additionally, the PR adds basic image cache trimming toiced_wgpu
.An image viewer example has been built to showcase a simple way to load remote images asynchronously.
Changelog
Added
image::Handle
type withfrom_path
andfrom_memory
methods.image::Data
enum representing different kinds of image data.Color::from_rgb8
to easily build aColor
from its hexadecimal representation.Changed
Image::new
takes anInto<image::Handle>
now instead of anInto<String>
.Fixed
Image
widget not keeping aspect ratio consistently.