Skip to content
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

Allow drawing of 1 BPP images with transparency #712

Open
rfuest opened this issue Nov 26, 2022 · 0 comments
Open

Allow drawing of 1 BPP images with transparency #712

rfuest opened this issue Nov 26, 2022 · 0 comments

Comments

@rfuest
Copy link
Member

rfuest commented Nov 26, 2022

This issue came up on the Matrix channel: It isn't currently easy to draw a 1 BPP image where the image data is used as an on-off alpha channel.

This feature could be implemented by the user, if images are providing a pixel iterator (see #609). But a more flexible solution would be to implement a DrawTarget adapter, which would work with all ImageDrawables and is already used by MonoFont: https://github.com/embedded-graphics/embedded-graphics/blob/master/src/mono_font/draw_target.rs

When a DrawTarget adapter is added it would also be possible to add an ImageDrawable wrapper, which internally uses the new DrawTarget adapter:

let image_1bpp = ImageRaw::<BinaryColor>::new(...);
let transparent_image = TransparentImage::new(image_1bpp, Rgb565::RED);

// transparent_image implements ImageDrawable<Color = Rgb565>
// and can be used like any other image
Image::new(&transparent_image, Point::zero()).draw(&mut display); 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant