agentlytics
Comprehensive analytics dashboard for AI coding agents — Cursor, Windsurf, Claude Code, VS Code Copilot, Zed, Antigravi…
A C library for color and black-and-white image dithering
git clone https://github.com/robertkist/libdither.gitrobertkist/libditherLibdither is a library for black-and-white and color image dithering, written in C (ANSI C99 standard). Libdither has no external dependencies and should compile easily on most current systems (e.g. Windows, Linux, MacOS). All you need is a C compiler.
This version of libdither is a Release Candidate: it has been tested and is working, but minor code cleanup is still required.
The black-and-white only libdither version can now be found in the libdither_mono branch.
Libdither MIT licensed, but the following code parts have their own permissive license:
Note: Palettes with a good range of hues and brightness, which matches the source image work best. If the overall palette is too dark, or too bright, the image, too, will be darker or brighte.
| Median-Cut: 16 colors error diffusion |
Wu: 16 colors error diffusion |
KD-Tree: 16 colors error diffusion |
![]() |
![]() |
![]() |
Note: Median-Cut and Wu are fairly fast, compared to KD-Tree. However, KD-Tree often gives the best results.
| Original | Median-Cut: 2 colors error diffusion |
Median-Cut: 4 colors error diffusion |
![]() |
![]() |
![]() |
| Median-Cut: 8 colors error diffusion |
Median-Cut: 16 colors error diffusion |
Median-Cut: 32 colors error diffusion |
![]() |
![]() |
![]() |
Note: With a palette that matches the original palette well, 32 colors are often sufficient.
Notes:
You need an ANSI C compiler and the make utility. Run make to display all build options.
By default, libdither is built for the current architecture.
Once compiled, you can find the finished library in the dist directory.
MacOS notes:
Linux notes:
gcc and make is all you need to build libdither. E.g. on Ubuntu you should install build-essential
via apt to get these tools.Windows notes - MinGW:
make via Chocolatey package manager from chocolatey.org (https://chocolatey.org/, https://chocolatey.org/packages/make)make libdither to build using MinGW.Windows notes - Microsoft Visual Studio Solution:
Windows notes - Microsoft Visual Studio (make):
make via Chocolatey package manager from chocolatey.org (https://chocolatey.org/, https://chocolatey.org/packages/make)make libdither_msvc to build (make sure to run Visual Studio's vcvars64.bat first!).sln) to build libdither from the Visual Studio IDE (2022 or newer).The src/demo example shows how to load an image (we use .bmp as it's an easy format to work with),
convert it to linear color space, dither it, and write it back to an output .bmp file. The demo was used
to create all the dithering examples you can see below.
You can also look at libdither.h, which includes commentary on how to use libdither.
In your own code, you only need to #include "libdither.h", which includes all public functions
and data structures, and link the libdither library, either statically or dynamically.
more like this
Comprehensive analytics dashboard for AI coding agents — Cursor, Windsurf, Claude Code, VS Code Copilot, Zed, Antigravi…
Free open-source Cloudflare R2 desktop client and S3 GUI for macOS, Windows, and Linux. Manage Cloudflare R2, AWS S3, M…
search projects, people, and tags