1 | use crate::util::*; |
2 | use crate::{ImageResult, ImageSize}; |
3 | |
4 | use std::io::{BufRead, Seek, SeekFrom}; |
5 | |
6 | pub fn size<R: BufRead + Seek>(reader: &mut R) -> ImageResult<ImageSize> { |
7 | // aseprite header: https://github.com/aseprite/aseprite/blob/main/docs/ase-file-specs.md#header |
8 | |
9 | reader.seek(pos:SeekFrom::Start(0x8))?; |
10 | |
11 | Ok(ImageSize { |
12 | width: read_u16(reader, &Endian::Little)? as usize, |
13 | height: read_u16(reader, &Endian::Little)? as usize, |
14 | }) |
15 | } |
16 | |
17 | pub fn matches(header: &[u8]) -> bool { |
18 | header.len() >= 12 && &header[4..6] == b" \xE0\xA5" |
19 | } |
20 | |