APNG Specification: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 26: Line 26:
To be recognized as an APNG, an `acTL` chunk must appear in the stream before any `IDAT` chunks. The `acTL` structure is described in the next section.
To be recognized as an APNG, an `acTL` chunk must appear in the stream before any `IDAT` chunks. The `acTL` structure is described in the next section.


An `fcTL` chunk must also appear before `IDAT`, providing frame information for the first frame encoded in the PNG stream's `IDAT` chunks, known as frame 0. If there is no fCTl chunk before IDAT, then frame 0 is intialized to RGBA(0,0,0,0) and the IDAT chunks are not used.
An `fcTL` chunk may also appear before `IDAT`, providing frame information for the first frame encoded in the PNG stream's `IDAT` chunks, known as frame 0. If there is no fcTL chunk before IDAT, then frame 0 is intialized to RGBA(0,0,0,0) and the IDAT chunks are not used.


Subsequent frames are encoded in `fdAT` chunks containing almost the same structure of content as IDAT chunks. Information for each frame about placement and rendering is stored in `fcTL` chunks.  The full layout of `fdAT` and `fcTL` chunks is described below.
Subsequent frames are encoded in `fdAT` chunks containing almost the same structure of content as IDAT chunks. Information for each frame about placement and rendering is stored in `fcTL` chunks.  The full layout of `fdAT` and `fcTL` chunks is described below.
Line 42: Line 42:
The `fcTL` and `fdAT` chunks have a 4 byte sequence number. Both chunk types share the sequence. The purpose of this number is to detect (and optionally correct) sequence errors in an Animated PNG, since the PNG specification does not impose orderng restrictions on ancillary chunks.
The `fcTL` and `fdAT` chunks have a 4 byte sequence number. Both chunk types share the sequence. The purpose of this number is to detect (and optionally correct) sequence errors in an Animated PNG, since the PNG specification does not impose orderng restrictions on ancillary chunks.


The first fCTl chunk must contain sequence number 0, and the sequence numbers in the remaining fCTl and fDAt chunks must be in order, with no gaps or duplicates.
The first fcTL chunk must contain sequence number 0, and the sequence numbers in the remaining fcTL and fdAT chunks must be in order, with no gaps or duplicates.


The table below illustrates the use of sequence numbers for images with more than one frame and more than one `fdAT` chunk:
The table below illustrates the use of sequence numbers for images with more than one frame and more than one `fdAT` chunk:
Line 56: Line 56:


     Sequence number    Chunk
     Sequence number    Chunk
     0                  fCTl describing frame 1
     0                  fcTL describing frame 1
     1                  first fDAt for frame 1
     1                  first fdAT for frame 1
     2                  second fDAt for frame 1
     2                  second fdAT for frame 1
     ....
     ....


Line 84: Line 84:
* For the second frame, the `fcTL` chunk must appear after the `IDAT` chunks from the first frame and before the fdAT chunks for the second frame.
* For the second frame, the `fcTL` chunk must appear after the `IDAT` chunks from the first frame and before the fdAT chunks for the second frame.
* For any subsequent frames, the `fcTL` chunk for the frame N must appear after the `fdAT` chunks from the frame N-1 and before the fdAT chunks for the frame N.
* For any subsequent frames, the `fcTL` chunk for the frame N must appear after the `fdAT` chunks from the frame N-1 and before the fdAT chunks for the frame N.
* Other ancillary chunks are allowed to appear among the APNG chunks, including between fDAt chunks. Decoders must ignore such chunks.
* Other ancillary chunks are allowed to appear among the APNG chunks, including between fdAT chunks.


The fCTl chunk is mandatory for every frame except for frame 0. When it is present for frame 0, decoders must render frame 0 from the data in the IDAT chunks.  When it is not present for frame 0, frame 0 is a transparent black frame (all pixels are RGBA(0,0,0,0)) and the IDAT chunks are ignored.  More than one fCTl chunk per frame is not allowed.
The fcTL chunk is mandatory for every frame except for frame 0. When it is present for frame 0, decoders must render frame 0 from the data in the IDAT chunks.  When it is not present for frame 0, frame 0 is a transparent black frame (all pixels are RGBA(0,0,0,0)) and the IDAT chunks are ignored.  More than one fcTL chunk per frame is not allowed.


Format:
Format:
Line 116: Line 116:
     4          APNG_DISPOSE_OP_PREVIOUS
     4          APNG_DISPOSE_OP_PREVIOUS


* APNG_DISPOSE_NONE: no disposal is done on this frame before rendering the next; its contents are left on the output buffer.  This is the default.
* APNG_DISPOSE_OP_NONE: no disposal is done on this frame before rendering the next; its contents are left on the output buffer.  This is the default.
* APNG_DISPOSE_OP_BACKGROUND: the frame's region is to be cleared to the background color. If no bKGD chunk is specified, the result is fully transparent black (r, g, b, and a all 0).
* APNG_DISPOSE_OP_BACKGROUND: the frame's region is to be cleared to the background color. If no bKGD chunk is specified, the result is fully transparent black (r, g, b, and a all 0).
* APNG_DISPOSE_OP_PREVIOUS: the frame's region is to be reverted to the previous contents.
* APNG_DISPOSE_OP_PREVIOUS: the frame's region is to be reverted to the previous contents.
Line 136: Line 136:
The `fdAT` chunk has the same purpose as an `IDAT` chunk. It has the same data structure as an `IDAT` chunk, except a sequence number is appended in the beginning.
The `fdAT` chunk has the same purpose as an `IDAT` chunk. It has the same data structure as an `IDAT` chunk, except a sequence number is appended in the beginning.


Each frame must contain at least one fDAt chunk. The compressed datastream is then the concatenation of the contents of the data fields of all the fDAt chunks within a frame.  When decompressed, the datastream is a complete PNG image, including the filter byte at the beginning of each scanline. It utilizes the same bit depth, color type, compression method, filter method, interlace method, and palette (if any) as the main image.
Each frame must contain at least one fdAT chunk. The compressed datastream is then the concatenation of the contents of the data fields of all the fdAT chunks within a frame.  When decompressed, the datastream is a complete PNG image, including the filter byte at the beginning of each scanline. It utilizes the same bit depth, color type, compression method, filter method, interlace method, and palette (if any) as the main image.


Format:
Format:
48

edits

Navigation menu