FastLED 3.9.15
Loading...
Searching...
No Matches
nsgif.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2004 Richard Wilson <richard.wilson@netsurf-browser.org>
3 * Copyright 2008 Sean Fox <dyntryx@gmail.com>
4 * Copyright 2013-2022 Michael Drake <tlsa@netsurf-browser.org>
5 *
6 * This file is part of NetSurf's libnsgif, http://www.netsurf-browser.org/
7 * Licenced under the MIT License,
8 * http://www.opensource.org/licenses/mit-license.php
9 */
10
15
16#pragma once
17
18#include "fl/stl/int.h"
19#include "fl/stl/noexcept.h"
20#include <stdbool.h>
21
22namespace fl {
23namespace third_party {
24
26#define NSGIF_INFINITE (0xFFFFFFFFU)
27
29#define NSGIF_MAX_COLOURS 256
30
34typedef struct nsgif nsgif_t;
35
44typedef struct nsgif_rect {
46 fl::u32 x0;
48 fl::u32 y0;
50 fl::u32 x1;
52 fl::u32 y1;
54
105
162
175typedef void nsgif_bitmap_t;
176
178typedef struct nsgif_bitmap_cb_vt {
186 nsgif_bitmap_t* (*create)(int width, int height);
187
193 void (*destroy)(nsgif_bitmap_t *bitmap);
194
205 fl::u8* (*get_buffer)(nsgif_bitmap_t *bitmap);
206
207 /* The following functions are optional. */
208
215 void (*set_opaque)(nsgif_bitmap_t *bitmap, bool opaque);
216
223 bool (*test_opaque)(nsgif_bitmap_t *bitmap);
224
230 void (*modified)(nsgif_bitmap_t *bitmap);
231
241 fl::u32 (*get_rowspan)(nsgif_bitmap_t *bitmap);
243
250const char *nsgif_strerror(nsgif_error err) FL_NOEXCEPT;
251
262 const nsgif_bitmap_cb_vt *bitmap_vt,
263 nsgif_bitmap_fmt_t bitmap_fmt,
264 nsgif_t **gif_out) FL_NOEXCEPT;
265
272
303 nsgif_t *gif,
304 fl::size size,
305 const fl::u8 *data) FL_NOEXCEPT;
306
323 nsgif_t *gif) FL_NOEXCEPT;
324
344 nsgif_t *gif,
345 nsgif_rect_t *area,
346 fl::u32 *delay_cs,
347 fl::u32 *frame_new) FL_NOEXCEPT;
348
360 nsgif_t *gif,
361 fl::u32 frame,
362 nsgif_bitmap_t **bitmap) FL_NOEXCEPT;
363
377 nsgif_t *gif) FL_NOEXCEPT;
378
382typedef struct nsgif_info {
384 fl::u32 width;
386 fl::u32 height;
388 fl::u32 frame_count;
392 fl::u32 background;
396
410
417const char *nsgif_str_disposal(enum nsgif_disposal disposal) FL_NOEXCEPT;
418
439
448
458 const nsgif_t *gif,
459 fl::u32 frame) FL_NOEXCEPT;
460
474 const nsgif_t *gif,
475 fl::u32 table[NSGIF_MAX_COLOURS],
476 fl::size *entries) FL_NOEXCEPT;
477
493 const nsgif_t *gif,
494 fl::u32 frame,
495 fl::u32 table[NSGIF_MAX_COLOURS],
496 fl::size *entries) FL_NOEXCEPT;
497
525 nsgif_t *gif,
526 fl::u16 delay_min,
527 fl::u16 delay_default) FL_NOEXCEPT;
528
529} // namespace third_party
530} // namespace fl
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition coder.h:132
nsgif_bitmap_fmt
NSGIF nsgif_bitmap_t pixel format.
Definition nsgif.hpp:117
@ NSGIF_BITMAP_FMT_A8B8G8R8
Bite-wise ABGR: Byte order: 0xAA, 0xBB, 0xGG, 0xRR.
Definition nsgif.hpp:128
@ NSGIF_BITMAP_FMT_R8G8B8A8
Bite-wise RGBA: Byte order: 0xRR, 0xGG, 0xBB, 0xAA.
Definition nsgif.hpp:119
@ NSGIF_BITMAP_FMT_ARGB8888
32-bit ARGB (0xAARRGGBB).
Definition nsgif.hpp:152
@ NSGIF_BITMAP_FMT_RGBA8888
32-bit RGBA (0xRRGGBBAA).
Definition nsgif.hpp:136
@ NSGIF_BITMAP_FMT_B8G8R8A8
Bite-wise BGRA: Byte order: 0xBB, 0xGG, 0xRR, 0xAA.
Definition nsgif.hpp:122
@ NSGIF_BITMAP_FMT_ABGR8888
32-bit BGRA (0xAABBGGRR).
Definition nsgif.hpp:160
@ NSGIF_BITMAP_FMT_BGRA8888
32-bit BGRA (0xBBGGRRAA).
Definition nsgif.hpp:144
@ NSGIF_BITMAP_FMT_A8R8G8B8
Bite-wise ARGB: Byte order: 0xAA, 0xRR, 0xGG, 0xBB.
Definition nsgif.hpp:125
void nsgif_set_frame_delay_behaviour(nsgif_t *gif, fl::u16 delay_min, fl::u16 delay_default) FL_NOEXCEPT
Configure handling of small frame delays.
Definition gif.cpp.hpp:1522
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_ERR_DATA_COMPLETE
Can't supply more data after calling nsgif_data_complete.
Definition nsgif.hpp:92
@ NSGIF_ERR_OOM
Out of memory error.
Definition nsgif.hpp:67
@ NSGIF_ERR_BAD_FRAME
Frame number is not valid.
Definition nsgif.hpp:77
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_ERR_ANIMATION_END
Indicates an animation is complete, and nsgif_reset must be called to restart the animation from the ...
Definition nsgif.hpp:103
@ NSGIF_ERR_DATA_FRAME
GIF source data contained an error in a frame.
Definition nsgif.hpp:82
@ NSGIF_ERR_DATA
GIF source data is invalid, and no frames are recoverable.
Definition nsgif.hpp:72
@ NSGIF_ERR_FRAME_DISPLAY
The current frame cannot be displayed.
Definition nsgif.hpp:97
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
struct fl::third_party::nsgif_rect nsgif_rect_t
LibNSGIF rectangle structure.
struct fl::third_party::nsgif_frame_info nsgif_frame_info_t
Information about a GIF frame.
nsgif_error nsgif_frame_prepare(nsgif_t *gif, nsgif_rect_t *area, fl::u32 *delay_cs, fl::u32 *frame_new) FL_NOEXCEPT
Prepare to show a frame.
Definition gif.cpp.hpp:1882
nsgif_error nsgif_data_scan(nsgif_t *gif, fl::size size, const fl::u8 *data) FL_NOEXCEPT
Scan the source image data.
Definition gif.cpp.hpp:1616
nsgif_error nsgif_frame_decode(nsgif_t *gif, fl::u32 frame, nsgif_bitmap_t **bitmap) FL_NOEXCEPT
Decodes a GIF frame.
Definition gif.cpp.hpp:1953
nsgif_disposal
Frame disposal method.
Definition nsgif.hpp:403
@ NSGIF_DISPOSAL_UNSPECIFIED
No disposal method specified.
Definition nsgif.hpp:404
@ NSGIF_DISPOSAL_NONE
Frame remains.
Definition nsgif.hpp:405
@ 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
struct fl::third_party::nsgif_bitmap_cb_vt nsgif_bitmap_cb_vt
Bitmap callbacks function table.
nsgif_error nsgif_create(const nsgif_bitmap_cb_vt *bitmap_vt, nsgif_bitmap_fmt_t bitmap_fmt, nsgif_t **gif_out) FL_NOEXCEPT
Create the NSGIF object.
Definition gif.cpp.hpp:1493
const nsgif_info_t * nsgif_get_info(const nsgif_t *gif) FL_NOEXCEPT
Get information about a GIF from an nsgif_t object.
Definition gif.cpp.hpp:1990
void nsgif_data_complete(nsgif_t *gif) FL_NOEXCEPT
Tell libnsgif that all the gif data has been provided.
Definition gif.cpp.hpp:1772
const char * nsgif_strerror(nsgif_error err) FL_NOEXCEPT
Convert an error code to a string.
Definition gif.cpp.hpp:2045
nsgif_error nsgif_reset(nsgif_t *gif) FL_NOEXCEPT
Reset a GIF animation.
Definition gif.cpp.hpp:1872
const char * nsgif_str_disposal(enum nsgif_disposal disposal) FL_NOEXCEPT
Convert a disposal method to a string.
Definition gif.cpp.hpp:2067
void nsgif_bitmap_t
Client bitmap type.
Definition nsgif.hpp:175
void nsgif_destroy(nsgif_t *gif) FL_NOEXCEPT
Free a NSGIF object.
Definition gif.cpp.hpp:1395
void nsgif_global_palette(const nsgif_t *gif, fl::u32 table[NSGIF_MAX_COLOURS], fl::size *entries) FL_NOEXCEPT
Get the global colour palette.
Definition gif.cpp.hpp:2008
struct fl::third_party::nsgif_info nsgif_info_t
Information about a GIF.
const nsgif_frame_info_t * nsgif_get_frame_info(const nsgif_t *gif, fl::u32 frame) FL_NOEXCEPT
Get information about a GIF from an nsgif_t object.
Definition gif.cpp.hpp:1996
struct nsgif nsgif_t
Opaque type used by LibNSGIF to represent a GIF object in memory.
Definition nsgif.hpp:34
bool nsgif_local_palette(const nsgif_t *gif, fl::u32 frame, fl::u32 table[NSGIF_MAX_COLOURS], fl::size *entries) FL_NOEXCEPT
Get the local colour palette for a frame.
Definition gif.cpp.hpp:2020
enum fl::third_party::nsgif_bitmap_fmt nsgif_bitmap_fmt_t
NSGIF nsgif_bitmap_t pixel format.
void(* modified)(nsgif_bitmap_t *bitmap)
Bitmap modified notification.
Definition nsgif.hpp:230
fl::u32(* get_rowspan)(nsgif_bitmap_t *bitmap)
Get row span in pixels.
Definition nsgif.hpp:241
nsgif_rect_t rect
Frame's redraw rectangle.
Definition nsgif.hpp:437
bool transparency
whether the frame may have transparency
Definition nsgif.hpp:426
bool local_palette
whether the frame has a local colour table
Definition nsgif.hpp:428
bool(* test_opaque)(nsgif_bitmap_t *bitmap)
Tests whether a bitmap has an opaque alpha channel.
Definition nsgif.hpp:223
int loop_max
number of times to play animation (zero means loop forever)
Definition nsgif.hpp:390
bool display
whether the frame should be displayed/animated
Definition nsgif.hpp:424
fl::u32 background
background colour in same pixel format as nsgif_bitmap_t.
Definition nsgif.hpp:392
void(* destroy)(nsgif_bitmap_t *bitmap)
Callback to free a bitmap.
Definition nsgif.hpp:193
fl::u32 frame_count
number of frames decoded
Definition nsgif.hpp:388
fl::u32 y0
y co-ordinate of redraw rectangle, top
Definition nsgif.hpp:48
fl::u32 width
width of GIF (may increase during decoding)
Definition nsgif.hpp:384
fl::u32 height
height of GIF (may increase during decoding)
Definition nsgif.hpp:386
bool interlaced
whether the frame is interlaced
Definition nsgif.hpp:430
fl::u32 delay
delay (in cs) before animating the frame
Definition nsgif.hpp:434
bool global_palette
whether the GIF has a global colour table
Definition nsgif.hpp:394
void(* set_opaque)(nsgif_bitmap_t *bitmap, bool opaque)
Set whether a bitmap can be plotted opaque.
Definition nsgif.hpp:215
fl::u32 x1
x co-ordinate of redraw rectangle, right
Definition nsgif.hpp:50
fl::u32 y1
y co-ordinate of redraw rectangle, bottom
Definition nsgif.hpp:52
fl::u32 x0
x co-ordinate of redraw rectangle, left
Definition nsgif.hpp:46
fl::u8 disposal
Disposal method for previous frame; affects plotting.
Definition nsgif.hpp:432
Information about a GIF.
Definition nsgif.hpp:382
LibNSGIF rectangle structure.
Definition nsgif.hpp:44
Information about a GIF frame.
Definition nsgif.hpp:422
GIF animation data.
Definition gif.cpp.hpp:71
Bitmap callbacks function table.
Definition nsgif.hpp:178
u8 u8 height
Definition blur.h:186
u8 width
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179
#define NSGIF_MAX_COLOURS
Maximum colour table size.
Definition nsgif.hpp:29
#define FL_NOEXCEPT