1 | use std::io::{BufRead, Seek, SeekFrom}; |
---|---|
2 | |
3 | use crate::{ |
4 | util::{read_u32, Endian}, |
5 | ImageResult, ImageSize, |
6 | }; |
7 | |
8 | pub fn size<R: BufRead + Seek>(reader: &mut R) -> ImageResult<ImageSize> { |
9 | reader.seek(pos:SeekFrom::Start(8))?; |
10 | |
11 | Ok(ImageSize { |
12 | width: read_u32(reader, &Endian::Big)? as usize, |
13 | height: read_u32(reader, &Endian::Big)? as usize, |
14 | }) |
15 | } |
16 | |
17 | pub fn matches(header: &[u8]) -> bool { |
18 | header.starts_with(needle:b"farbfeld") |
19 | } |
20 |