-
Notifications
You must be signed in to change notification settings - Fork 14
/
png.grammar
380 lines (380 loc) · 19.6 KB
/
png.grammar
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?xml version="1.0" encoding="UTF-8"?>
<ufwb version="1.3.1">
<grammar name="PNG Images" start="id:45" author="Andreas Pehnack" fileextension="png" uti="public.png">
<description>Grammar for the popular PNG image file format</description>
<structure name="Defaults" id="46" encoding="ISO_8859-1:1987" endian="big" signed="no">
<description>
Defines the default values.
</description>
</structure>
<structure name="Header" id="48" extends="id:46" encoding="ISO_8859-1:1987" endian="big" signed="no">
<binary name="Eye catcher" mustmatch="yes" id="49" fillcolor="DE83F7" length="8">
<fixedvalues>
<fixedvalue name="Eye catcher" value="89504E470D0A1A0A"/>
</fixedvalues>
</binary>
</structure>
<structure name="Chunk" id="51" extends="id:46" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="Length" id="52" fillcolor="54FA8A" type="integer" length="4"/>
<number name="Type" mustmatch="yes" id="53" fillcolor="68D6FB" type="integer" length="4" display="hex"/>
<structure name="Data" id="54" length="prev.Length" fillcolor="FEFB8C"/>
<binary name="CRC" id="56" fillcolor="FFD385" length="4"/>
</structure>
<structure name="IHDR" id="58" extends="id:51">
<number name="Length" id="59" type="integer"/>
<number name="Type" id="60" type="integer">
<fixedvalues>
<fixedvalue name="IHDR" value="0x49484452"/>
</fixedvalues>
</number>
<structure name="Data" id="61">
<number name="Width" id="62" type="integer" length="4"/>
<number name="Height" id="63" type="integer" length="4"/>
<number name="Bit depth" id="64" type="integer" length="1">
<fixedvalues>
<fixedvalue value="1"></fixedvalue>
<fixedvalue value="2"></fixedvalue>
<fixedvalue value="4"></fixedvalue>
<fixedvalue value="8"></fixedvalue>
<fixedvalue value="16"></fixedvalue>
</fixedvalues>
</number>
<number name="Color type" id="65" type="integer" length="1">
<fixedvalues>
<fixedvalue name="Type0" value="0">
<description>
Each pixel is a grayscale sample.
</description>
</fixedvalue>
<fixedvalue name="Type2" value="2">
<description>
Each pixel is an R,G,B triple.
</description>
</fixedvalue>
<fixedvalue name="Type3" value="3">
<description>
Each pixel is a palette index; a PLTE chunk must appear.
</description>
</fixedvalue>
<fixedvalue name="Type4" value="4">
<description>
Each pixel is a grayscale sample, followed by an alpha sample.
</description>
</fixedvalue>
<fixedvalue name="Type6" value="6">
<description>
Each pixel is an R,G,B triple, followed by an alpha sample.
</description>
</fixedvalue>
</fixedvalues>
</number>
<number name="Compression method" id="66" type="integer" length="1">
<fixedvalues>
<fixedvalue name="deflate/inflate" value="0">
<description>
deflate/inflate compression with a sliding window of at most 32768 bytes
</description>
</fixedvalue>
</fixedvalues>
</number>
<number name="Filter method" id="67" type="integer" length="1">
<fixedvalues>
<fixedvalue name="Adaptive" value="0"/>
</fixedvalues>
</number>
<number name="Interlace method" id="68" type="integer" length="1">
<fixedvalues>
<fixedvalue name="No interlace" value="0"/>
<fixedvalue name="Adam7 interlace" value="1"/>
</fixedvalues>
</number>
</structure>
<binary name="CRC" id="70"/>
</structure>
<structure name="tIME" id="72" extends="id:51">
<number name="Length" id="73" type="integer"/>
<number name="Type" id="74" type="integer">
<fixedvalues>
<fixedvalue value="0x74494D45"/>
</fixedvalues>
</number>
<structure name="Data" id="75">
<number name="Year" id="76" type="integer" length="2"/>
<number name="Month" id="77" type="integer" length="1"/>
<number name="Day" id="78" type="integer" length="1"/>
<number name="Hour" id="79" type="integer" length="1"/>
<number name="Minute" id="80" type="integer" length="1"/>
<number name="Second" id="81" type="integer" length="1"/>
</structure>
<binary name="CRC" id="83"/>
</structure>
<structure name="tEXt" id="85" extends="id:51" floating="yes">
<number name="Length" id="86" type="integer"/>
<number name="Type" id="87" type="integer">
<fixedvalues>
<fixedvalue value="0x74455874"/>
</fixedvalues>
</number>
<structure name="Data" id="88">
<string name="Key" id="89" type="zero-terminated"/>
<string name="Text" id="90" type="zero-terminated"/>
</structure>
<binary name="CRC" id="92"/>
</structure>
<structure name="zTXt" id="94" extends="id:51" floating="yes">
<number name="Length" id="95" type="integer"/>
<number name="Type" id="96" type="integer">
<fixedvalues>
<fixedvalue value="0x7A545874"/>
</fixedvalues>
</number>
<structure name="Data" id="97">
<string name="Key" id="98" type="zero-terminated"/>
<number name="Compression method" id="99" type="integer" length="1">
<fixedvalues>
<fixedvalue name="zlib with deflate" value="0"><description>zlib datastream with deflate compression</description></fixedvalue>
</fixedvalues>
</number>
<binary name="Compressed Text" id="100" length="remaining"/>
</structure>
<binary name="CRC" id="102"/>
</structure>
<structure name="iTXt" id="104" extends="id:51" floating="yes">
<number name="Length" id="105" type="integer"/>
<number name="Type" id="106" type="integer">
<fixedvalues>
<fixedvalue value="0x69545874"/>
</fixedvalues>
</number>
<structure name="Data" id="107">
<string name="Key" id="108" type="zero-terminated"/>
<number name="Compression flag" id="109" type="integer" length="1">
<fixedvalues>
<fixedvalue name="Uncompressed" value="0"><description>Uncompressed text</description></fixedvalue>
<fixedvalue name="Compressed" value="1"><description>Compressed text</description></fixedvalue>
</fixedvalues>
</number>
<number name="Compression method" id="110" type="integer" length="1">
<fixedvalues>
<fixedvalue name="zlib with deflate" value="0"><description>zlib datastream with deflate compression</description></fixedvalue>
</fixedvalues>
</number>
<string name="Language tag" id="111" type="zero-terminated"/>
<string name="Translated keyword" id="112" type="zero-terminated"/>
<string name="Text" id="113" type="zero-terminated"/>
</structure>
<binary name="CRC" id="115"/>
</structure>
<structure name="iCCP" id="117" extends="id:51">
<number name="Length" id="118" type="integer"/>
<number name="Type" id="119" type="integer">
<fixedvalues>
<fixedvalue value="0x69434350"/>
</fixedvalues>
</number>
<structure name="Data" id="120">
<string name="Profile name" id="121" type="zero-terminated"/>
<number name="Compression method" id="122" type="integer" length="1">
<fixedvalues>
<fixedvalue name="zlib with deflate" value="0"><description>zlib datastream with deflate compression</description></fixedvalue>
</fixedvalues>
</number>
<number name="Compressed profile" id="123" type="integer" length="1"/>
</structure>
<binary name="CRC" id="125"/>
</structure>
<structure name="tRNS" id="127" extends="id:51">
<number name="Length" id="128" type="integer"/>
<number name="Type" id="129" type="integer">
<fixedvalues>
<fixedvalue value="0x74524E53"/>
</fixedvalues>
</number>
<structure name="Data" id="130">
<structure name="Color" id="131" repeatmax="unlimited">
<number name="Red" id="132" type="integer" length="1"/>
<number name="Green" id="133" type="integer" length="1"/>
<number name="Blue" id="134" type="integer" length="1"/>
</structure>
</structure>
<binary name="CRC" id="137"/>
</structure>
<structure name="gAMA" id="139" extends="id:51">
<number name="Length" id="140" type="integer"/>
<number name="Type" id="141" type="integer">
<fixedvalues>
<fixedvalue value="0x67414D41"/>
</fixedvalues>
</number>
<structure name="Data" id="142">
<number name="Gamma" id="143" type="integer" length="4"/>
</structure>
<binary name="CRC" id="145"/>
</structure>
<structure name="cHRM" id="147" extends="id:51">
<description>
Applications that need device-independent specification of colors in a PNG file can use the cHRM chunk to specify the 1931 CIE x,y chromaticities of the red, green, and blue primaries used in the image, and the referenced white point
</description>
<number name="Length" id="148" type="integer"/>
<number name="Type" id="149" type="integer">
<fixedvalues>
<fixedvalue value="0x6348524D"/>
</fixedvalues>
</number>
<structure name="Data" id="150">
<number name="White Point x" id="151" type="integer" length="4"/>
<number name="White Point y" id="152" type="integer" length="4"/>
<number name="Red x" id="153" type="integer" length="4"/>
<number name="Red y" id="154" type="integer" length="4"/>
<number name="Green x" id="155" type="integer" length="4"/>
<number name="Green y" id="156" type="integer" length="4"/>
<number name="Blue x" id="157" type="integer" length="4"/>
<number name="Blue y" id="158" type="integer" length="4"/>
</structure>
<binary name="CRC" id="160"/>
</structure>
<structure name="PLTE" id="162" extends="id:51">
<number name="Length" id="163" type="integer"/>
<number name="Type" id="164" type="integer">
<fixedvalues>
<fixedvalue value="0x504C5445"/>
</fixedvalues>
</number>
<structure name="Data" id="165">
<structure name="Color" id="166" repeatmax="unlimited">
<number name="Red" id="167" fillcolor="FF0000" type="integer" length="1"/>
<number name="Green" id="168" fillcolor="00FF00" type="integer" length="1"/>
<number name="Blue" id="169" fillcolor="0000FF" type="integer" length="1"/>
</structure>
</structure>
<binary name="CRC" id="172"/>
</structure>
<structure name="hIST" id="174" extends="id:51">
<number name="Length" id="175" type="integer"/>
<number name="Type" id="176" type="integer">
<fixedvalues>
<fixedvalue value="0x68495354"/>
</fixedvalues>
</number>
<structure name="Data" id="177">
<number name="Count" id="178" type="integer" length="2" repeatmax="unlimited"/>
</structure>
<binary name="CRC" id="180"/>
</structure>
<structure name="bKGD" id="182" extends="id:51">
<number name="Length" id="183" type="integer"/>
<number name="Type" id="184" type="integer">
<fixedvalues>
<fixedvalue value="0x624B4744"/>
</fixedvalues>
</number>
<structure name="Data" id="185">
<binary name="Color Data" id="186" length="remaining"/>
</structure>
<binary name="CRC" id="187"/>
</structure>
<structure name="pHYs" id="189" extends="id:51">
<number name="Length" id="190" type="integer"/>
<number name="Type" id="191" type="integer">
<fixedvalues>
<fixedvalue value="0x70485973"/>
</fixedvalues>
</number>
<structure name="Data" id="192">
<number name="Pixels per unit, x axis" id="193" type="integer" length="4"/>
<number name="Pixels per unit, y axis" id="194" type="integer" length="4"/>
<number name="Unit specifier" id="195" type="integer" length="1">
<fixedvalues>
<fixedvalue name="unit is unknown" value="0"/>
<fixedvalue name="unit is the metre" value="1"/>
</fixedvalues>
</number>
</structure>
<binary name="CRC" id="197"/>
</structure>
<structure name="sPLT" id="199" extends="id:51">
<number name="Length" id="200" type="integer"/>
<number name="Type" id="201" type="integer">
<fixedvalues>
<fixedvalue value="0x73504C54"/>
</fixedvalues>
</number>
<structure name="Data" id="202">
<string name="Palette name" id="203" type="zero-terminated"/>
<number name="Sample depth" id="204" type="integer" length="1"/>
<structure name="Color" id="205" repeatmax="unlimited">
<number name="Red" id="206" fillcolor="FF0000" type="integer" length="1"/>
<number name="Green" id="207" fillcolor="00FF00" type="integer" length="1"/>
<number name="Blue" id="208" fillcolor="0000FF" type="integer" length="1"/>
</structure>
</structure>
<binary name="CRC" id="211"/>
</structure>
<structure name="sRGB" id="213" extends="id:51" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="Length" id="214" type="integer"/>
<number name="Type" id="215" type="integer" display="hex">
<fixedvalues>
<fixedvalue value="0x73524742"/>
</fixedvalues>
</number>
<binary name="CRC" id="218"/>
</structure>
<structure name="IDAT" id="220" extends="id:51">
<number name="Length" id="221" type="integer"/>
<number name="Type" id="222" type="integer">
<fixedvalues>
<fixedvalue value="0x49444154"/>
</fixedvalues>
</number>
<structure name="Data" id="223">
<binary name="Image Data" id="224" length="remaining"/>
</structure>
<binary name="CRC" id="226"/>
</structure>
<structure name="sBIT" id="228" extends="id:51">
<number name="Length" id="229" type="integer"/>
<number name="Type" id="230" type="integer">
<fixedvalues>
<fixedvalue value="0x73424954"/>
</fixedvalues>
</number>
<structure name="Data" id="231">
<binary name="SignificantBits" id="232" length="remaining"/>
</structure>
<binary name="CRC" id="234"/>
</structure>
<structure name="IEND" id="236" extends="id:51">
<number name="Length" id="237" type="integer"/>
<number name="Type" id="238" type="integer">
<fixedvalues>
<fixedvalue value="0x49454E44"/>
</fixedvalues>
</number>
<binary name="CRC" id="241"/>
</structure>
<structure name="PNG File" id="45" extends="id:46" consists-of="id:46" encoding="ISO_8859-1:1987" endian="big" signed="no">
<structref name="Header" id="243" structure="id:48"/>
<structref name="IHDR" id="244" structure="id:58"/>
<structure name="Chunks" id="245" repeatmax="unlimited" order="variable">
<structref name="tIME" id="246" repeatmin="0" structure="id:72"/>
<structref name="iCCP" id="247" repeatmin="0" structure="id:117"/>
<structref name="gAMA" id="248" repeatmin="0" structure="id:139"/>
<structref name="cHRM" id="249" repeatmin="0" structure="id:147"/>
<structref name="pHYs" id="250" repeatmin="0" structure="id:189"/>
<structref name="PLTE" id="251" repeatmin="0" structure="id:162"/>
<structref name="bKGD" id="252" repeatmin="0" structure="id:182"/>
<structref name="IDAT" id="253" repeatmin="0" repeatmax="unlimited" structure="id:220"/>
<structref name="iTXt" id="254" repeatmin="0" repeatmax="unlimited" structure="id:104"/>
<structref name="zTXt" id="255" repeatmin="0" repeatmax="unlimited" structure="id:94"/>
<structref name="tEXt" id="256" repeatmin="0" repeatmax="unlimited" structure="id:85"/>
<structref name="tRNS" id="257" repeatmin="0" structure="id:127"/>
<structref name="hIST" id="258" repeatmin="0" structure="id:174"/>
<structref name="sBIT" id="259" repeatmin="0" structure="id:228"/>
<structref name="sPLT" id="260" repeatmin="0" structure="id:199"/>
<structref name="sRGB" id="261" repeatmin="0" structure="id:213"/>
<structref name="IEND" id="262" repeatmin="0" structure="id:236"/>
<structref name="Chunk" id="263" structure="id:51"/>
</structure>
</structure>
</grammar>
</ufwb>