Image: Type annotations required when creating ImageBuffer

Created on 5 Dec 2015  路  3Comments  路  Source: image-rs/image

Hi!
I'm kind of new with Rust so bare with me :)

Im getting this error:

src/main.rs:70:22: 70:45 error: type annotations required: cannot resolve `<_ as image::buffer::Pixel>::Subpixel == _` [E0284]
src/main.rs:70     let mut imgbuf = image::ImageBuffer::new(width as u32, height as u32);

I tried specializing with the Rgba pixel type like this:

 let mut imgbuf = image::ImageBuffer::new<image::Rgba>(width as u32, height as u32);

but it didnt work.

Any ideas?

Thanks a lot!
Fran

help wanted

Most helpful comment

Here, Ill give you this present for your help (I've done it with this lib)
example1

All 3 comments

Try

let mut imgbuf: image::ImageBuffer<image::Rgba<u8>, _> = image::ImageBuffer::new(width as u32, height as u32);

instead.

let mut imgbuf: image::RgbaImage = image::ImageBuffer::new(width as u32, height as u32);

is an alias for that.

Thanks! It worked!

Here, Ill give you this present for your help (I've done it with this lib)
example1

Was this page helpful?
0 / 5 - 0 ratings