-
Notifications
You must be signed in to change notification settings - Fork 13
/
PNG.spec
executable file
·65 lines (53 loc) · 1.36 KB
/
PNG.spec
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
/**
* A specification file for PNG images
* http://www.libpng.org/pub/png/spec/1.1/PNG-Structure.html
*/
Defining Collection PNG {
// http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html
Collection CHUNK {
ULONG Length
ASCII[4] ChunkType
COLLECTION<ChunkType> OR BYTE[Length] ChunkData // there may be unknown chunks, so we use data-array fallback.
ULONG CRC
}
ULONG signature_1
if(signature_1 != 0x89504E47) {
TERMINATE No valid PNG file signature found
}
ULONG signature_2
if(signature_2 != 0x0D0A1A0A) {
TERMINATE No valid PNG file signature found
}
// if we get here, we have a legal PNG file
// and we can start reading in chunks.
CHUNK[REMAINDER] chunks
}
// http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.IHDR
Collection IHDR {
ULONG Width
ULONG Height
BYTE BitDepth
BYTE ColorYype
BYTE CompressionMethod
BYTE FilterMethod
BYTE InterlaceMethod
}
// http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.IEND
Collection IEND {}
// http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.pHYs
Collection pHYs {
ULONG PixelsPerUnitXaxis
ULONG PixelsPerUnitYaxis
BYTE UnitSpecifier
}
// http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.cHRM
Collection cHRM {
ULONG WhitePointC
ULONG WhitePointY
ULONG RedX
ULONG RedY
ULONG GreenX
ULONG GreenY
ULONG BlueX
ULONG BlueY
}