(bytes: &[u8])
| 333 | } |
| 334 | |
| 335 | fn hex_encode(bytes: &[u8]) -> String { |
| 336 | const HEX_CHARS: &[u8; 16] = b"0123456789abcdef"; |
| 337 | let mut hex = String::with_capacity(bytes.len() * 2); |
| 338 | for &byte in bytes { |
| 339 | hex.push(HEX_CHARS[(byte >> 4) as usize] as char); |
| 340 | hex.push(HEX_CHARS[(byte & 0xf) as usize] as char); |
| 341 | } |
| 342 | hex |
| 343 | } |
| 344 | |
| 345 | fn encode_rgba_to_png(rgba_data: &[u8], width: u32, height: u32) -> Result<Vec<u8>, ArchiveError> { |
| 346 | let img: RgbaImage = ImageBuffer::from_raw(width, height, rgba_data.to_vec()) |