Skip to content

Commit

Permalink
patterns/png: add cHRM and tIME chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
applecuckoo committed Oct 17, 2024
1 parent 27d034a commit 3d0d819
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion patterns/png.hexpat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma description PNG image
#pragma description PNG image files

#pragma MIME image/png
#pragma endian big
Expand Down Expand Up @@ -121,6 +121,26 @@ struct palette_entry_t {
u24 color;
} [[inline]];

struct chrm_t {
u32 white_point_x;
u32 white_point_y;
u32 red_x;
u32 red_y;
u32 green_x;
u32 green_y;
u32 blue_x;
u32 blue_y;
};

struct time_t {
u16 year;
u8 month;
u8 day;
u8 hour;
u8 minute;
u8 second;
};

struct chunk_t {
u32 length [[color("17BECF")]];
char name[4];
Expand All @@ -139,6 +159,8 @@ struct chunk_t {
#define acTL_k "acTL"
#define fdAT_k "fdAT"
#define fcTL_k "fcTL"
#define cHRM_k "cHRM"
#define tIME_k "tIME"

if (name == IHDR_k) {
ihdr_t ihdr [[comment("Image Header chunk"), name("IHDR")]];
Expand Down Expand Up @@ -167,6 +189,10 @@ struct chunk_t {
} else if (name == fdAT_k) {
fdat_t fdat [[comment("Frame data chunk")]];
u8 data[length-sizeof(u32)];
} else if (name == cHRM_k) {
chrm_t chrm;
} else if (name == tIME_k) {
time_t time;
} else {
u8 data[length];
}
Expand Down

0 comments on commit 3d0d819

Please sign in to comment.