You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-14Lines changed: 42 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
4
4
A fast and lightweight GIF encoder that can create GIF animations and images. Summary of the main features:
5
5
- user-defined global or local color-palette with up to 256 colors (limit of the GIF format)
6
+
- True Color to GIF conversion (RGB/RGBA input) with quantization and dithering
6
7
- size-optimizations for GIF animations:
7
8
- option to set a pixel to transparent if it has identical color in the previous frame (transparency optimization)
8
9
- do encoding just for the rectangular area that differs from the previous frame (width/height optimization)
@@ -11,28 +12,40 @@ A fast and lightweight GIF encoder that can create GIF animations and images. Su
11
12
- different options for GIF animations: static image, N repetitions, infinite repetitions
12
13
- additional source-code for verifying the encoder after making changes
13
14
- user-defined delay time from one frame to the next (can be set independently for each frame)
15
+
- stream-based output (via callback)
14
16
- source-code conforms to the C99 standard
15
17
16
18
## Examples
17
-
To get started, we suggest that you have a look at our code examples. ```examples/cgif_example_video.c``` is an example that creates a GIF animation. ```examples/cgif_example.c``` is an example for a static GIF image.
19
+
To get started, we suggest that you have a look at our code examples.
20
+
-```examples/cgif_example_video.c``` is an example that creates a GIF animation.
21
+
-```examples/cgif_example.c``` is an example for a static GIF image.
22
+
-```examples/cgif_rgb_example_video.c``` is an example that creates a GIF animation from RGB data.
23
+
-```examples/cgif_rgb_example.c``` is an example for a static GIF image from RGB data.
18
24
19
25
## Overview
20
-
To get an overview of the API, we recommend having a look at our wiki (https://github.com/dloebl/cgif/wiki/General-API) where types and functions are described. The corresponding implementations can be found in ```src/cgif.c```and ```src/cgif_raw.c```. Here the most important types and functions:
26
+
To get an overview of the API, we recommend having a look at our wiki (https://github.com/dloebl/cgif/wiki/General-API) where types and functions are described. The corresponding implementations can be found in ```src/cgif.c```, ```src/cgif_raw.c```, and ```src/cgif_rgb.c```. Here the most important types and functions:
21
27
22
28
```C
23
-
// These are the four struct types that contain all GIF data and parameters:
24
-
typedef CGIF_Config // global cofinguration parameters of the GIF
29
+
// These are the struct types that contain all GIF data and parameters:
30
+
typedef CGIF_Config // global configuration parameters of the GIF
25
31
typedef CGIF_FrameConfig // local configuration parameters for a frame
26
-
typedefCGIF// struct for the full GIF
27
-
typedef CGIF_Frame // struct for a single frame
32
+
typedefCGIF// struct for the full GIF
33
+
typedef CGIFrgb_Config // global cofinguration parameters of the RGB GIF
34
+
typedef CGIFrgb_FrameConfig // local configuration parameters for an RGB frame
35
+
typedef CGIFrgb // struct for the full RGB GIF
28
36
29
-
// The user needs only these three functions to create a GIF image:
37
+
// The user needs only these functions to create a GIF image:
30
38
CGIF* cgif_newgif (CGIF_Config* pConfig); // creates a new GIF
31
39
int cgif_addframe (CGIF* pGIF, CGIF_FrameConfig* pConfig); // adds a frame to an existing GIF
32
-
int cgif_close (CGIF* pGIF); // close the created file and free memory
40
+
int cgif_close (CGIF* pGIF); // close the created file and free memory
41
+
42
+
// The user needs only these functions to create a GIF image from RGB data:
With our encoder you can create animated or static GIFs, you can or cannot use certain optimizations, and so on. You can switch between all these different options easily using the two attributes ```attrFlags``` and ```genFlags``` in the configurations ```CGIF_Config``` and ```CGIF_FrameConfig```. These attributes are of type ```uint32_t``` and bundle yes/no-options with a bit-wise logic. So far only a few of the 32 bits are used leaving space to include further functionalities ensuring backward compatibility. We provide the following flag settings which can be combined by bit-wise or-operations:
48
+
With our encoder you can create animated or static GIFs, you can or cannot use certain optimizations, and so on. You can switch between all these different options easily using the two attributes ```attrFlags``` and ```genFlags``` in the configurations ```CGIF_Config``` and ```CGIF_FrameConfig``` (or their RGB counterparts). These attributes are of type ```uint32_t``` and bundle yes/no-options with a bit-wise logic. So far only a few of the 32 bits are used leaving space to include further functionalities ensuring backward compatibility. We provide the following flag settings which can be combined by bit-wise or-operations:
36
49
```C
37
50
CGIF_ATTR_IS_ANIMATED // make an animated GIF (default is non-animated GIF)
38
51
CGIF_ATTR_NO_GLOBAL_TABLE // disable global color table (global color table is default)
@@ -45,19 +58,34 @@ CGIF_FRAME_ATTR_HAS_SET_TRANS // transparency setting provided by user (tra
If you didn't understand the point of ```attrFlags``` and ```genFlags``` and the flags, please don't worry. The example files ```examples/cgif_example.c``` and ```examples/cgif_example_video.c```are all you need to get started and the used default settings for ```attrFlags``` and ```genFlags``` cover most cases quite well.
66
+
If you didn't understand the point of ```attrFlags``` and ```genFlags``` and the flags, please don't worry. The example files are all you need to get started and the used default settings cover most cases quite well.
Alternatively, you can use the Meson build system:
75
+
```
76
+
$ meson build
77
+
$ cd build
78
+
$ ninja
79
+
$ ./examples/cgif_example
57
80
```
58
81
59
82
## Validating the encoder
60
-
In the folder ```tests```, we provide several testing routines that you can run via the script ```tests/performtests.sh```. To perform the tests you need to install the programs [ImageMagick](https://github.com/ImageMagick/ImageMagick), [gifsicle](https://github.com/kohler/gifsicle) and [tcc (tiny c compiler)](https://bellard.org/tcc/).
83
+
In the folder ```tests```, we provide several testing routines that you can run via Meson.
84
+
```
85
+
$ meson build
86
+
$ cd build
87
+
$ meson test
88
+
```
61
89
With the provided tests you can validate that the encoder still generates correct GIF files after making changes on the encoder itself.
62
90
63
91
## Further explanations
@@ -70,7 +98,7 @@ The following additional guarantees are provided:
70
98
* Public API of versions 0.x.x are stable.
71
99
72
100
## Debugging
73
-
There is a Visual Studio Code debug configuration with launch targets for the two examples. You need to install the C/C++ extension and a LLDB extension (debugger) to debug cgif.
101
+
There is a Visual Studio Code debug configuration with launch targets for the examples. You need to install the C/C++ extension and a LLDB extension (debugger) to debug cgif.
0 commit comments