A widget similar to a image::Viewer that lets you view bitmap data but with added enhancements.
What sets this apart is that you can freely modify the image data without re-allocating or resorting to locks. This is good if you need to display frequently changing image data.
Instead of using image::Handle, this crate provides iced_texture_canvas::Bitmap an rgba buffer stored on the CPU.
And to view that buffer, you use iced_texture_canvas::texture_canvas.
use iced_texture_canvas::{bitmap, texture_canvas};
// create your bitmap image
let mut bitmap = bitmap(500, 500);
// fill it with color
bitmap.buffer_mut().fill(0xffffffff);
// display it in your view method
texture_canvas(&bitmap)The api also takes a few inspirations from MouseArea
cargo run -p demo
- API improvements
- Explore abstracting over image formats instead of just rgba.
- Use a texture atlas for efficiently drawing multiple textures.
- Layering + overlay support in canvas space.
- A static viewer analogous to the image widget.
- Only works if you're using the wgpu renderer.