// The PNG magic number. export const magic: [_]u8 = [137, 80, 78, 71, 13, 10, 26, 10]; def MAGIC_LEN: size = 8; // The chunk header type for an IHDR chunk. export def IHDR: u32 = 0x49484452; // The chunk header type for a PLTE chunk. export def PLTE: u32 = 0x504c5445; // The chunk header type for an IDAT chunk. export def IDAT: u32 = 0x49444154; // The chunk header type for an IEND chunk. export def IEND: u32 = 0x49454e44; // The chunk header type for a tRNS chunk. export def TRNS: u32 = 0x74524e53; // The chunk header type for a gAMA chunk. export def GAMA: u32 = 0x67414d41; // The chunk header type for an sRGB chunk. export def SRGB: u32 = 0x73524742; // The chunk header type for an iCCP chunk. export def ICCP: u32 = 0x69434350; // The chunk header type for a tEXT chunk. export def TEXT: u32 = 0x74455854; // The chunk header type for a zTXT chunk. export def ZTXT: u32 = 0x7a545854; // The chunk header type for an iTXT chunk. export def ITXT: u32 = 0x69545854; // The chunk header type for a bKGD chunk. export def BKGD: u32 = 0x624b4744; // The chunk header type for a pHYS chunk. export def PHYS: u32 = 0x70485953; // The chunk header type for a sBIT chunk. export def SBIT: u32 = 0x73424954; // The chunk header type for a sPLT chunk. export def SPLT: u32 = 0x73504c54; // The chunk header type for a hIST chunk. export def HIST: u32 = 0x68495354; // The chunk header type for a tIME chunk. export def TIME: u32 = 0x74494d45; // Returns true if the given chunk type is a "critical" chunk. export fn is_critical(ctype: u32) bool = { return ctype & (1 << 29) == 0; }; @test fn is_critical() void = { assert(is_critical(IHDR) == true); assert(is_critical(PLTE) == true); assert(is_critical(IDAT) == true); assert(is_critical(IEND) == true); assert(is_critical(HIST) == false); assert(is_critical(TIME) == false); };