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

Issues trying to draw embedded graphics image #130

Closed
mangelajo opened this issue Dec 1, 2022 · 3 comments · Fixed by #132
Closed

Issues trying to draw embedded graphics image #130

mangelajo opened this issue Dec 1, 2022 · 3 comments · Fixed by #132

Comments

@mangelajo
Copy link
Contributor

163 | let bus = Image::new(&ImageRaw::new(include_bytes!("../../icons/Bus.raw"), 30),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait From<()> is not implemented for epd_waveshare::color::Color
|

I guess it's missing some conversions?

It's defined as

impl<'a, C, BO> ImageRaw<'a, C, BO>
where
    C: PixelColor + From<<C as PixelColor>::Raw>,
    BO: ByteOrder,
{

I also tried creating a BinaryColor raw image, but then I cannot draw it on a "Color" display.

would it be possible to standardize into "BinaryColor" from embedded_graphics?, I could be missing lots of things, ... still new to rust.

@mangelajo
Copy link
Contributor Author

Hmm, I am getting it to work by adding this to color.rs:

#[cfg(feature = "graphics")]
impl From<BinaryColor> for Color {
    fn from(b: BinaryColor) -> Color {
        match b {
            BinaryColor::On => Color::Black,
            BinaryColor::Off => Color::White,
        }
    }
}

and then adding .color_converted() to the display:


    bus.draw(&mut display.translated(Point::new(100,100)).color_converted()).unwrap();
     

@peckpeck
Copy link
Contributor

peckpeck commented Dec 3, 2022

yes some traits are missing to work with every color

@peckpeck
Copy link
Contributor

peckpeck commented Dec 5, 2022

Fixed in #132

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

Successfully merging a pull request may close this issue.

2 participants