Closed ollyde closed 7 months ago
@Cykooz is there any convenience to convert this to PNG?
@ollyde
ColorSpace:Rgb(...)
@Cykooz thanks, I see the planes stuff on the home page; but it's confusing. Was hoping there was just a convert_to_format or something simple.
https://github.com/Cykooz/libheif-rs
You must use planes. It is raw buffer with pixels data.
let handle = context.primary_image_handle().unwrap();
let chroma = if handle.has_alpha_channel() {
RgbChroma::Rgba
} else {
RgbChroma::Rgb
};
let image = lib_hef.decode(&handle, ColorSpace::Rgb(chroma), None).unwrap();
let planes = image.planes();
if let Some(buffer) = planes.interleaved {
// `buffer` is raw buffer with RGB(A) pixels
}
@Cykooz thanks for you help, but it's too complex, decided to use image-magic, has a one liner for bytes :-)
We have
let image_file_bytes: Vec<u8>
in our control flow which is HEICHow can we load it into the context without file?
let lib_heif = LibHeif::new();