1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Code cleanup

This commit is contained in:
Emil Ernerfeldt
2020-11-20 19:50:47 +01:00
parent ebf204a9ae
commit 99a2a52510
4 changed files with 167 additions and 137 deletions

View File

@@ -6,9 +6,21 @@ pub struct Texture {
pub version: u64,
pub width: usize,
pub height: usize,
/// luminance and alpha, linear space 0-255
pub pixels: Vec<u8>,
}
impl Texture {
/// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom.
pub fn srgba_pixels<'slf>(&'slf self) -> impl Iterator<Item = super::Srgba> + 'slf {
use super::Srgba;
let srgba_from_luminance_lut: Vec<Srgba> = (0..=255).map(Srgba::white_alpha).collect();
self.pixels
.iter()
.map(move |&l| srgba_from_luminance_lut[l as usize])
}
}
impl std::ops::Index<(usize, usize)> for Texture {
type Output = u8;