apng(png)

png(portable network graphics) is the raster, composed of binary data.
png is composed in order '89 50 4e 47 0d 0a 1a 0a'(hex), IHDRchunk, other chunks, IENDchunk.
chunk is composed in order length, type, data, crc.
crc(cyclic redundancy check) is generated from type and data.

apng(animated portable network graphics) is png with chunks added in order acTL, fcTL, fdAT.

chunk

category name length
(4bytes)
type
(4bytes)
data
(?)
crc
(4bytes)
png IHDR
00 00 00 0d
49 48 44 52
13bytes 4bytes
png PLTE 4bytes
50 4c 54 45
? 4bytes IHDR color_type = 3
apng acTL
00 00 00 08
61 63 54 4c
8bytes 4bytes
png IDAT 4bytes
49 44 41 54
? 4bytes
apng fcTL
00 00 00 1a
66 63 54 4c
26bytes 4bytes
apng fdAT 4bytes
66 64 41 54
? 4bytes
png IEND
00 00 00 00
49 45 4e 44
0byte
ae 42 60 82


IHDR


data

width
(4bytes)
height
(4bytes)
bit_depth
(1byte)
color_type
(1byte)
compression_method
(1byte)
filter_method
(1byte)
interlace_method
(1byte)
1,2,4,8,16 0 grayscale
8,16 2 rgb
1,2,4,8 3 PLTE
8,16 4 grayscale(alpha)
8,16 6 rgb(alpha)


PLTE


data

palette
(1byte)
...


acTL


data

num_frames
(4bytes)
num_plays
(4bytes)


fcTL


data

sequence_mumber
(4bytes)
width
(4bytes)
height
(4bytes)
x_offset
(4bytes)
y_offset
(4bytes)
deley_num
(2bytes)
deley_den
(2bytes)
dispose_op
(1byte)
blend_op
(1byte)


fdAT


data

sequence_mumber
(4bytes)
frame_data
(?)