pxl8/src/pxl8_ase.h

99 lines
1.8 KiB
C
Raw Normal View History

2025-08-13 15:04:49 -05:00
#pragma once
2025-08-13 15:04:49 -05:00
#include "pxl8_types.h"
#define PXL8_ASE_MAGIC 0xA5E0
#define PXL8_ASE_FRAME_MAGIC 0xF1FA
#define PXL8_ASE_CHUNK_CEL 0x2005
#define PXL8_ASE_CHUNK_LAYER 0x2004
#define PXL8_ASE_CHUNK_OLD_PALETTE 0x0004
#define PXL8_ASE_CHUNK_PALETTE 0x2019
typedef struct pxl8_ase_header {
u32 file_size;
u16 magic;
u16 frames;
u16 width;
u16 height;
u16 color_depth;
u32 flags;
u16 speed;
u32 transparent_index;
u8 n_colors;
u8 pixel_width;
u8 pixel_height;
i16 grid_x;
i16 grid_y;
u16 grid_width;
u16 grid_height;
} pxl8_ase_header;
typedef struct pxl8_ase_frame_header {
u32 frame_bytes;
u16 magic;
u16 chunks;
u16 duration;
} pxl8_ase_frame_header;
typedef struct pxl8_ase_chunk_header {
u32 chunk_size;
u16 chunk_type;
} pxl8_ase_chunk_header;
typedef struct pxl8_ase_cel {
u16 layer_index;
i16 x;
i16 y;
u8 opacity;
u16 cel_type;
u16 width;
u16 height;
u8* pixel_data;
} pxl8_ase_cel;
typedef struct pxl8_ase_layer {
u16 flags;
u16 layer_type;
u16 child_level;
u16 blend_mode;
u8 opacity;
char* name;
} pxl8_ase_layer;
typedef struct pxl8_ase_palette {
u32 entry_count;
u32 first_color;
u32 last_color;
u32* colors;
} pxl8_ase_palette;
typedef struct pxl8_ase_frame {
u16 frame_id;
u16 width;
u16 height;
i16 x;
i16 y;
u16 duration;
u8* pixels;
} pxl8_ase_frame;
typedef struct pxl8_ase_file {
u32 frame_count;
pxl8_ase_frame* frames;
pxl8_ase_header header;
u32 layer_count;
pxl8_ase_layer* layers;
pxl8_ase_palette palette;
} pxl8_ase_file;
#ifdef __cplusplus
extern "C" {
#endif
pxl8_result pxl8_ase_load(const char* filepath, pxl8_ase_file* ase_file);
void pxl8_ase_free(pxl8_ase_file* ase_file);
#ifdef __cplusplus
}
#endif