APNG Specification: Difference between revisions

no edit summary
(APNG 0.9)
No edit summary
Line 98: Line 98:
     20    delay_num            (unsigned short) Frame delay fraction numerator
     20    delay_num            (unsigned short) Frame delay fraction numerator
     22    delay_den            (unsigned short) Frame delay fraction denominator
     22    delay_den            (unsigned short) Frame delay fraction denominator
     24    render_op            (byte)          Type of output buffer area disposal to be done after rendering this frame
     24    dispose_op            (byte)          Type of frame area disposal to be done after rendering this frame
    25    blend_op              (byte)          Type of frame area rendering for this frame  


The frame must be rendered within the region defined by the `width`, `height`, `x_offset` and `y_offset` from the `fcTL`, and the width and height from the `IHDR` chunk.
The frame must be rendered within the region defined by the `width`, `height`, `x_offset` and `y_offset` from the `fcTL`, and the width and height from the `IHDR` chunk.
Line 108: Line 109:
The `delay_num` and `delay_den` parameters together specify a fraction indicating the delay after the current frame, in seconds.  If the denominator is 0, it is to be treated as if it were 100 (that is, delay_num then specifies 1/100ths of a second).  If the the value of the numerator is 0 the decoder should render the next frame as quickly as possible, though viewers may impose a reasonable lower bound on the delay.
The `delay_num` and `delay_den` parameters together specify a fraction indicating the delay after the current frame, in seconds.  If the denominator is 0, it is to be treated as if it were 100 (that is, delay_num then specifies 1/100ths of a second).  If the the value of the numerator is 0 the decoder should render the next frame as quickly as possible, though viewers may impose a reasonable lower bound on the delay.


The `render_op` parameter contains flags describing how the frame is to be disposed before rendering the next frame; it also specifies whether the frame is to be alpha blended into the current output buffer content, or whether it should completely replace its region in the output buffer.  Valid render_op flags are:
Valid values for `dispose_op` are:


     bit
     value
     +-------------------------------+
     1          APNG_DISPOSE_OP_NONE
     | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
     2           APNG_DISPOSE_OP_BACKGROUND
     +-----------------|---|---|---|-+
     4          APNG_DISPOSE_OP_PREVIOUS
                      |  +---+---+------ bits 0-2: dispose_op
                      |
                      +------------------ bit 3: APNG_RENDER_OP_BLEND_FLAG


* 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_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.


Bits 4 through 7 are reserved and must be 0.
`blend_op` specifies whether the frame is to be alpha blended into the current output buffer content, or whether it should completely replace its region in the output buffer. Valid `blend_op` values are:


Valid values for `dispose_op` are:
    value
    0      APNG_BLEND_OP_SOURCE
    1      APNG_BLEND_OP_OVER


    value  bit
If `blend_op` is APNG_BLEND_OP_SOURCE all color components of the frame, including alpha, overwrite the current contents of the frame's output buffer region. If `blend_op` is APNG_BLEND_OP_OVER the frame should be composited onto the output buffer based on its alpha, using a simple OVER operation as described in the "Alpha Channel Processing" section of the PNG specification [PNG-1.2]. Note that Variation 2 of the sample code is applicable.
    1     0    APNG_RENDER_OP_DISPOSE_NONE
    2     1    APNG_RENDER_OP_DISPOSE_BACKGROUND
    4      2     APNG_RENDER_OP_DISPOSE_PREVIOUS


* `APNG_RENDER_OP_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_BLEND_OP_OVER is not valid for color types 0 (greyscale without alpha) or 2 (truecolor without alpha). It is valid for type 3 (indexed) images; however, the resulting pixel values may not be present in the specified palette. It is always valid for type 4 (greyscale with alpha) and type 6 (truecolor with alpha) images.
* `APNG_RENDER_OP_DISPOSE_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_RENDER_OP_DISPOSE_PREVIOUS`: the frame's region is to be reverted to the previous contents.


`APNG_RENDER_OP_BLEND_FLAG` may be added to any of the above disposal operations.  If this flag is 0, all color components of the frame, including alpha, overwrite the current contents of the frame's output buffer region.  If the APNG_RENDER_OP_BLEND_FLAG is not 0 the frame should be composited onto the output buffer based on its alpha, using a simple OVER operation as described in the "Alpha Channel Processing" section of the PNG specification [pngspec]. Note
`blend_op` must be APNG_BLEND_OP_SOURCE for frame 0.
that Variation 2 of the sample code is applicable.
 
`APNG_RENDER_OP_BLEND_FLAG` is not valid for color types 0 (greyscale without alpha) or 2 (truecolor without alpha).  It is valid for type 3 (indexed) images; however, the resulting pixel values may not be present in the specified palette.  It is always valid for type 4 (greyscale with alpha) and type 6 (truecolor with alpha) images.
 
APNG_RENDER_OP_BLEND_FLAG must be 0 for frame 0.


== `fdAT`: The Frame Data Chunk ==
== `fdAT`: The Frame Data Chunk ==
Line 243: Line 236:


* The acTL fcTL and adAT are now not copy safe, renamed them to acTL, fcTL and adAT
* The acTL fcTL and adAT are now not copy safe, renamed them to acTL, fcTL and adAT
* Split dispose_op into render_op and blend_op


= Test Encoder and Sample Images =
= Test Encoder and Sample Images =
48

edits