Rename GP_Context -> GP_Pixmap
[gfxprim.git] / include / filters / GP_Dither.h
blob024544d3ee4e6d2e8a06fa15ac1af828c2e37a38
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 Dithering algorithms.
29 #ifndef FILTERS_GP_DITHER_H
30 #define FILTERS_GP_DITHER_H
32 #include "GP_Filter.h"
35 * Classical Floyd-Steinberg. Produces good results and is a little faster than
36 * the Hilbert-Peano dithering.
38 * The error is distributed to the neighbor pixels as follows:
39 * (X denotes current position)
42 * | |
43 * | X | 7/16
44 * | |
45 * -----------------------
46 * | |
47 * 3/16 | 5/16 | 1/16
48 * | |
53 * Converts RGB888 24bit image to any RGB or Grayscale bitmap.
55 * The source pixel_type MUST BE GP_PIXEL_RGB888.
57 * The destination must be at least as large as source.
59 * If operation was aborted from within a callback, non-zero is returned.
61 int GP_FilterFloydSteinberg(const GP_Pixmap *src,
62 GP_Pixmap *dst,
63 GP_ProgressCallback *callback);
66 * If malloc() has failed, or operation was aborted by a callback, NULL is
67 * returned.
69 GP_Pixmap *GP_FilterFloydSteinbergAlloc(const GP_Pixmap *src,
70 GP_PixelType pixel_type,
71 GP_ProgressCallback *callback);
74 * Hilbert-Peano space filling curve based dithering.
76 * The error value is distributed around the Hilbert curve.
78 * This dithering introduces a little more noisy result but doesn't create
79 * repeating patterns like Floyd-Steinberg which looks generally better to
80 * human eye. On the other hand edges tend to be less sharp.
84 * Converts RGB888 24bit image to any RGB or Grayscale bitmap.
86 * The source pixel_type MUST BE GP_PIXEL_RGB888.
88 * The destination must be at least as large as source.
90 * If the operation was aborted from within a callback, non-zero is returned.
92 int GP_FilterHilbertPeano(const GP_Pixmap *src,
93 GP_Pixmap *dst,
94 GP_ProgressCallback *callback);
97 * If malloc() has failed, or operation was aborted by a callback, NULL is
98 * returned.
100 GP_Pixmap *GP_FilterHilbertPeanoAlloc(const GP_Pixmap *src,
101 GP_PixelType pixel_type,
102 GP_ProgressCallback *callback);
104 #endif /* FILTERS_GP_DITHER_H */