#include <gfxprim.h> /* or */ #include <filters/gp_dither.h> int gp_filter_floyd_steinberg(const gp_pixmap *src, gp_pixmap *dst, gp_progress_cb *callback);
Currently there are two dithering algorithms implemented. Both takes an RGB888 24bit image as input and are able to produce any RGB or Grayscale image. This filters doesn’t work in-place as the result has different pixel type.
Classical Floyd-Steinberg. Produces good results and is a little faster than the Hilbert-Peano dithering.
The error is distributed to neighbor pixels as follows:
X |
7/16 |
|
3/16 |
5/16 |
1/16 |
And is throwed away at the image borders.
#include <gfxprim.h> /* or */ #include <filters/gp_dither.h> int gp_filter_floyd_steinberg(const gp_pixmap *src, gp_pixmap *dst, gp_progress_cb *callback);
Renders Floyd Steinberg dithering directly into passed pixmap. The destination must be at least as large as source.
If operation was aborted by a callback, non-zero is returned.
Not all pixel types all supported. If particular combination is not supported the function returns non-zero and sets errno to ENOSYS.
#include <gfxprim.h> /* or */ #include <filters/gp_dither.h> gp_pixmap *gp_filter_floyd_steinberg_alloc(const gp_pixmap *src, gp_pixel_type pixel_type, gp_progress_cb *callback);
Returns pointer to allocated pixmap of given pixel_type.
If malloc(2) has failed, or operation was aborted by a callback NULL is returned.
Not all pixel types all supported. If particular combination is not supported the function returns NULL and sets errno to ENOSYS.
Hilbert-Peano space filling curve based dithering.
The error value is distributed around the Hilbert curve.
The result is a little more noisy, but doesn’t create repeating patterns like Floyd-Steinberg which looks generally better to human eye. On the other hand edges tend to be less sharp.
#include <gfxprim.h> /* or */ #include <filters/gp_dither.h> int gp_filter_hilbert_peano(const gp_pixmap *src, gp_pixmap *dst, gp_progress_cb *callback);
Renders Hilbert Peano dithering directly into passed pixmap. The destination must be at least as large as source.
If operation was aborted by a callback, non-zero is returned.
Not all pixel types all supported. If particular combination is not supported the function returns NULL and sets errno to ENOSYS.
#include <gfxprim.h> /* or */ #include <filters/gp_dither.h> gp_pixmap *gp_filter_hilbert_peano_alloc(const gp_pixmap *src, gp_pixel_type pixel_type, gp_progress_cb *callback);
Returns pointer to allocated pixmap of given pixel_type.
If malloc(2) has failed, or operation was aborted by a callback NULL is returned.
Not all pixel types all supported. If particular combination is not supported the function returns NULL and sets errno to ENOSYS.