aseprite_loader/binary/chunks/
cel_extra.rs1use bitflags::bitflags;
2
3use crate::binary::{
4 errors::ParseResult,
5 scalars::{dword, fixed, Dword, Fixed},
6};
7
8#[derive(Debug)]
9pub struct CelExtraChunk<'a> {
10 pub flags: CelExtraFlags,
11 pub precise_x_position: Fixed,
12 pub precise_y_position: Fixed,
13 pub width_of_the_cel: Fixed,
14 pub height_of_the_cel: Fixed,
15 pub future: &'a [u8],
16}
17
18bitflags! {
19 #[derive(Debug)]
20 pub struct CelExtraFlags: Dword {
21 const PRECISE_BOUNDS_ARE_SET = 0x1;
22 }
23}
24
25pub fn parse_cel_extra_chunk(input: &[u8]) -> ParseResult<'_, CelExtraChunk<'_>> {
26 let (input, flags) = dword(input)?;
27 let (input, precise_x_position) = fixed(input)?;
28 let (input, precise_y_position) = fixed(input)?;
29 let (input, width_of_the_cel) = fixed(input)?;
30 let (input, height_of_the_cel) = fixed(input)?;
31 Ok((
32 &input[input.len()..],
33 CelExtraChunk {
34 flags: CelExtraFlags::from_bits_truncate(flags),
35 precise_x_position,
36 precise_y_position,
37 width_of_the_cel,
38 height_of_the_cel,
39 future: input,
40 },
41 ))
42}