How could one determine the bit depth of a image::DynamicImage in rust? I'm using fltk-rs function for creating an RgbImageand RgbImage::new() requires that I specify the bit depth of the Rgb byte data its going to be created from. The images I'm loading in my program have various bit depths, so I need to be able to determine the bit depth value for image dynamically.
impl RgbImage
pub fn new(
data: &[u8],
w: u32,
h: u32,
depth: u32
) -> Result<RgbImage, FltkError>
Here's a typical use case where I would like to know the bit depth of my DynamicImage:
image = "0.23.12"
fltk = "0.12.0"
use image::*;
use fltk::*;
//...
let img = image::open("my_img.png").unwrap(); //<---find the bit depth of this loaded image
let (imgx, imgy) = img.dimensions();
let fltk_rgb = RgbImage::new(&img.to_bytes(), imgx, imgy, 4).unwrap(); //<---then use bit depth value here
//...