Open Bauxitedev opened 3 years ago
I'm not sure. There's into_vec()
on ImageBuffer
(RgbaImage
is an alias of ImageBuffer
), which will give you Vec<u8>
, but then you need to make it Vec<RGBA>
. Rust doesn't have safe methods for that yet.
You could easily borrow the buffer to make Img<&[RGBA]>
:
use rgb::FromSlice;
ImgRef::new(img.as_rgba(), img.width(), img.height())
I'm using the
image
crate to load images, and I was wondering: is there a method to easily and quickly convert a loadedRgbaImage
into anImg
? Right now I'm doing it manually like this:I was wondering if it is possible to do this in a one-liner. I was also wondering if it was possible to do it the other way around...