#type conversions

3 messages · Page 1 of 1 (latest)

jaunty dirge
#

In Rust I would like to know if there's a way to convert an array of u8 bytes to a PNG or something similar. IDAT chunks typically can be represented as u8 bytes, so I was just wondering if this was possible. I know PNG images themselves contain multiple layers like IDAT chunks, PNG magic, and an IHDR chunk typically. So the reconstruction of a PNG of image from u8 bytes without the original PNG image to u8 conversion logic within the code (so i'm just pulling the IDAT chunk bytes externally and storing them in an u8 array variable like [u8;size]) would be a bit different I would assume. I'm clueless tbf. I know you can convert (in my case) something like a &[u8] slice to UTF-8 through something like from_utf8_lossy.

cobalt junco
#

you probably are interested in bytemuck if you want to construct types from raw bytes

#

?crate bytemuck