image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.94k stars 613 forks source link

How do you change a pixel? #304

Closed quadrupleslap closed 9 years ago

quadrupleslap commented 9 years ago

Probably the wrong place to ask this, but how do I change a pixel to full transparency?

I can make a transparent pixel (image::Rgba([0, 0, 0, 0]);), but whenever I try setting it (img.put_pixel(x, y, tranparent_pixel);), I can't, because rust-image expects a trait I can't even use:

 expected `<GenericImage as image::image::GenericImage>::Pixel`,
    found `image::color::Rgba<_>`
(expected associated type,
    found struct `image::color::Rgba`) [E0308]
nwin commented 9 years ago

The right place to ask and continue this discussion would be http://www.reddit.com/r/rust_gamedev/

In any case please post a complete minimal examples that compiles that reproduces the error next time. As it is now I can just speculate that you have to convert the image to rgba first by using to_rgba or ˚convert' depending on the context.

quadrupleslap commented 9 years ago

Thanks! =)