Skip to content

Commit 3c29ad5

Browse files
authored
Merge pull request #86 from dloebl/dloebl/update-readme
Update README
2 parents c8c6a9e + f819c06 commit 3c29ad5

1 file changed

Lines changed: 42 additions & 14 deletions

File tree

README.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
A fast and lightweight GIF encoder that can create GIF animations and images. Summary of the main features:
55
- 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
67
- size-optimizations for GIF animations:
78
- option to set a pixel to transparent if it has identical color in the previous frame (transparency optimization)
89
- 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
1112
- different options for GIF animations: static image, N repetitions, infinite repetitions
1213
- additional source-code for verifying the encoder after making changes
1314
- user-defined delay time from one frame to the next (can be set independently for each frame)
15+
- stream-based output (via callback)
1416
- source-code conforms to the C99 standard
1517

1618
## 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.
1824

1925
## 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:
2127

2228
```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
2531
typedef CGIF_FrameConfig // local configuration parameters for a frame
26-
typedef CGIF // struct for the full GIF
27-
typedef CGIF_Frame // struct for a single frame
32+
typedef CGIF // 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
2836

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:
3038
CGIF* cgif_newgif (CGIF_Config* pConfig); // creates a new GIF
3139
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:
43+
CGIFrgb* cgif_rgb_newgif (const CGIFrgb_Config* pConfig);
44+
cgif_result cgif_rgb_addframe (CGIFrgb* pGIF, const CGIFrgb_FrameConfig* pConfig);
45+
cgif_result cgif_rgb_close (CGIFrgb* pGIF);
3346
```
3447
35-
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:
3649
```C
3750
CGIF_ATTR_IS_ANIMATED // make an animated GIF (default is non-animated GIF)
3851
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
4558
CGIF_FRAME_ATTR_INTERLACED // encode frame interlaced
4659
CGIF_FRAME_GEN_USE_TRANSPARENCY // use transparency optimization (size optimization)
4760
CGIF_FRAME_GEN_USE_DIFF_WINDOW // do encoding just for the sub-window that changed (size optimization)
61+
62+
// Flags specific to the RGB API:
63+
CGIF_RGB_FRAME_ATTR_INTERLACED // encode frame interlaced
64+
CGIF_RGB_FRAME_ATTR_NO_DITHERING // disable dithering
4865
```
49-
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.
5067

5168
## Compiling the example
5269
An example can be compiled and tested simply by:
5370
```
54-
$ c99 -o cgif_example -Iinc examples/cgif_example_video.c src/cgif.c src/cgif_raw.c
71+
$ c99 -o cgif_example -Iinc examples/cgif_example_video.c src/cgif.c src/cgif_raw.c src/cgif_rgb.c
5572
$ ./cgif_example
56-
73+
```
74+
Alternatively, you can use the Meson build system:
75+
```
76+
$ meson build
77+
$ cd build
78+
$ ninja
79+
$ ./examples/cgif_example
5780
```
5881

5982
## 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+
```
6189
With the provided tests you can validate that the encoder still generates correct GIF files after making changes on the encoder itself.
6290

6391
## Further explanations
@@ -70,7 +98,7 @@ The following additional guarantees are provided:
7098
* Public API of versions 0.x.x are stable.
7199

72100
## 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.
74102

75103
## License
76104
Licensed under the MIT license (permissive).

0 commit comments

Comments
 (0)