blob: b970175f4d72a2b3de5713bd0feaf57402dc5eee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// 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);
};
|