1use lz4::{decompress};
4
5#[derive(Clone, Copy)]
7pub struct Bitmap<'a> {
8 width: u16,
9 height: u16,
10 data: &'a [u8],
11}
12impl<'a> Bitmap<'a> {
13 pub fn width(&self) -> u16 {
15 self.width
16 }
17 pub fn height(&self) -> u16 {
19 self.height
20 }
21 pub fn len(&self) -> u32 {
23 self.width as u32 * self.height as u32 * 4
24 }
25 pub unsafe fn construct(data: &'a [u8], width: u16, height: u16) -> Bitmap<'a> {
27 Bitmap { width: width, height: height, data: data }
28 }
29 pub fn data(&self, out: &mut [u8]) {
31 assert_eq!(out.len(), self.len() as usize);
32 let len = decompress(self.data, out);
33 assert_eq!(len, Ok(self.len() as usize));
34 }
35}