FastLED 3.9.15
Loading...
Searching...
No Matches

◆ nsgif__parse_extension_graphic_control()

static nsgif_error fl::third_party::nsgif__parse_extension_graphic_control ( struct nsgif_frame * frame,
const fl::u8 * data,
fl::size len )
static

Parse the graphic control extension.

Parameters
[in]frameThe gif frame object we're decoding.
[in]dataThe data to decode.
[in]lenByte length of data.
Returns
NSGIF_ERR_END_OF_DATA if more data is needed, NSGIF_OK for success.

Definition at line 756 of file gif.cpp.hpp.

760{
761 enum {
762 GIF_MASK_TRANSPARENCY = 0x01,
763 GIF_MASK_DISPOSAL = 0x1c,
764 };
765
766 /* 6-byte Graphic Control Extension is:
767 *
768 * +0 CHAR Graphic Control Label
769 * +1 CHAR Block Size
770 * +2 CHAR __Packed Fields__
771 * 3BITS Reserved
772 * 3BITS Disposal Method
773 * 1BIT User Input Flag
774 * 1BIT Transparent Color Flag
775 * +3 SHORT Delay Time
776 * +5 CHAR Transparent Color Index
777 */
778 if (len < 6) {
780 }
781
782 frame->info.delay = data[3] | (data[4] << 8);
783
784 if (data[2] & GIF_MASK_TRANSPARENCY) {
785 frame->info.transparency = true;
786 frame->transparency_index = data[5];
787 }
788
789 frame->info.disposal = ((data[2] & GIF_MASK_DISPOSAL) >> 2);
790 /* I have encountered documentation and GIFs in the
791 * wild that use 0x04 to restore the previous frame,
792 * rather than the officially documented 0x03. I
793 * believe some (older?) software may even actually
794 * export this way. We handle this as a type of
795 * "quirks" mode. */
798 }
799
800 /* if we are clearing the background then we need to
801 * redraw enough to cover the previous frame too. */
802 frame->redraw_required =
805
806 return NSGIF_OK;
807}
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
@ NSGIF_DISPOSAL_RESTORE_BG
Clear frame to background colour.
Definition nsgif.hpp:406
@ NSGIF_DISPOSAL_RESTORE_PREV
Restore previous frame.
Definition nsgif.hpp:407
@ NSGIF_DISPOSAL_RESTORE_QUIRK
Alias for NSGIF_DISPOSAL_RESTORE_PREV.
Definition nsgif.hpp:408
bool redraw_required
whether a full image redraw is required
Definition gif.cpp.hpp:47
bool transparency
whether the frame may have transparency
Definition nsgif.hpp:426
fl::u32 delay
delay (in cs) before animating the frame
Definition nsgif.hpp:434
fl::u32 transparency_index
the index designating a transparent pixel
Definition gif.cpp.hpp:53
struct nsgif_frame_info info
Definition gif.cpp.hpp:38
fl::u8 disposal
Disposal method for previous frame; affects plotting.
Definition nsgif.hpp:432

References FL_NOEXCEPT, NSGIF_DISPOSAL_RESTORE_BG, NSGIF_DISPOSAL_RESTORE_PREV, NSGIF_DISPOSAL_RESTORE_QUIRK, NSGIF_ERR_END_OF_DATA, and NSGIF_OK.

Referenced by nsgif__parse_frame_extensions().

+ Here is the caller graph for this function: