(&mut self, texture_id: TextureId, data: TSrc)
| 75 | /// |
| 76 | #[cfg(feature = "image-loading")] |
| 77 | fn load_texture<TSrc: io::BufRead+io::Read+io::Seek>(&mut self, texture_id: TextureId, data: TSrc) -> Option<(usize, usize)> { |
| 78 | // Load the image |
| 79 | let img = ImageReader::new(data).with_guessed_format().ok()?; |
| 80 | let img = img.decode().ok()?; |
| 81 | |
| 82 | // Convert to 8-bit RGBA |
| 83 | let img = img.into_rgba8(); |
| 84 | let width = img.width(); |
| 85 | let height = img.height(); |
| 86 | |
| 87 | // Load the texture |
| 88 | let raw_pixels = Arc::new(img.into_raw()); |
| 89 | self.create_texture(texture_id, width, height, TextureFormat::Rgba); |
| 90 | self.set_texture_bytes(texture_id, 0, 0, width, height, raw_pixels); |
| 91 | |
| 92 | // Result is the image size |
| 93 | Some((width as _, height as _)) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /// |
no test coverage detected