Rework the encoder, replace all unsafe code

This commit is contained in:
Ivan Smirnov 2021-12-30 18:01:16 +03:00
commit 6ce544950d
2 changed files with 49 additions and 57 deletions

View file

@ -8,6 +8,15 @@ impl<const N: usize> Pixel<N> {
Self([0; N])
}
#[inline]
pub fn read(&mut self, s: &[u8]) {
let mut i = 0;
while i < N {
self.0[i] = s[i];
i += 1;
}
}
#[inline]
pub const fn as_rgba(self, with_a: u8) -> Pixel<4> {
let mut i = 0;