1 /*****************************************************************************
2 * This file is part of gfxprim library. *
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. *
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. *
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 *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Point filters, these works on individual pixels.
29 #ifndef FILTERS_GP_POINT_H
30 #define FILTERS_GP_POINT_H
32 #include "GP_Filter.h"
37 * Increments each pixel channel by a p * channel_max value.
39 int GP_FilterBrightnessEx(const GP_Pixmap
*const src
,
40 GP_Coord x_src
, GP_Coord y_src
,
41 GP_Size w_src
, GP_Size h_src
,
43 GP_Coord x_dst
, GP_Coord y_dst
,
45 GP_ProgressCallback
*callback
);
47 GP_Pixmap
*GP_FilterBrightnessExAlloc(const GP_Pixmap
*const src
,
48 GP_Coord x_src
, GP_Coord y_src
,
49 GP_Size w_src
, GP_Size h_src
,
51 GP_ProgressCallback
*callback
);
53 static inline int GP_FilterBrightness(const GP_Pixmap
*src
, GP_Pixmap
*dst
,
54 float p
, GP_ProgressCallback
*callback
)
56 return GP_FilterBrightnessEx(src
, 0, 0, src
->w
, src
->h
,
57 dst
, 0, 0, p
, callback
);
60 static inline GP_Pixmap
*
61 GP_FilterBrightnessAlloc(const GP_Pixmap
*src
, float p
,
62 GP_ProgressCallback
*callback
)
64 return GP_FilterBrightnessExAlloc(src
, 0, 0, src
->w
, src
->h
,
71 * Multiplies each pixel channel by a given float value.
73 * The parameters should have the same pixel channels as
74 * source pixel type and are expected to be float numbers.
76 int GP_FilterContrastEx(const GP_Pixmap
*const src
,
77 GP_Coord x_src
, GP_Coord y_src
,
78 GP_Size w_src
, GP_Size h_src
,
80 GP_Coord x_dst
, GP_Coord y_dst
,
82 GP_ProgressCallback
*callback
);
84 GP_Pixmap
*GP_FilterContrastExAlloc(const GP_Pixmap
*const src
,
85 GP_Coord x_src
, GP_Coord y_src
,
86 GP_Size w_src
, GP_Size h_src
,
88 GP_ProgressCallback
*callback
);
90 static inline int GP_FilterContrast(const GP_Pixmap
*src
, GP_Pixmap
*dst
,
91 float p
, GP_ProgressCallback
*callback
)
93 return GP_FilterContrastEx(src
, 0, 0, src
->w
, src
->h
,
94 dst
, 0, 0, p
, callback
);
97 static inline GP_Pixmap
*GP_FilterContrastAlloc(const GP_Pixmap
*src
,
99 GP_ProgressCallback
*callback
)
101 return GP_FilterContrastExAlloc(src
, 0, 0, src
->w
, src
->h
,
106 * Brightness and Contrast combined.
108 int GP_FilterBrightnessContrastEx(const GP_Pixmap
*const src
,
109 GP_Coord x_src
, GP_Coord y_src
,
110 GP_Size w_src
, GP_Size h_src
,
112 GP_Coord x_dst
, GP_Coord y_dst
,
114 GP_ProgressCallback
*callback
);
116 GP_Pixmap
*GP_FilterBrightnessContrastExAlloc(const GP_Pixmap
*const src
,
117 GP_Coord x_src
, GP_Coord y_src
,
118 GP_Size w_src
, GP_Size h_src
,
120 GP_ProgressCallback
*callback
);
122 GP_FilterBrightnessContrast(const GP_Pixmap
*src
, GP_Pixmap
*dst
,
123 float b
, float c
, GP_ProgressCallback
*callback
)
125 return GP_FilterBrightnessContrastEx(src
, 0, 0, src
->w
, src
->h
,
126 dst
, 0, 0, b
, c
, callback
);
129 static inline GP_Pixmap
*
130 GP_FilterBrightnessContrastAlloc(const GP_Pixmap
*src
,
132 GP_ProgressCallback
*callback
)
134 return GP_FilterBrightnessContrastExAlloc(src
, 0, 0, src
->w
, src
->h
,
141 * Does quantization into steps regions.
143 int GP_FilterPosterizeEx(const GP_Pixmap
*const src
,
144 GP_Coord x_src
, GP_Coord y_src
,
145 GP_Size w_src
, GP_Size h_src
,
147 GP_Coord x_dst
, GP_Coord y_dst
,
149 GP_ProgressCallback
*callback
);
151 GP_Pixmap
*GP_FilterPosterizeExAlloc(const GP_Pixmap
*const src
,
152 GP_Coord x_src
, GP_Coord y_src
,
153 GP_Size w_src
, GP_Size h_src
,
155 GP_ProgressCallback
*callback
);
157 static inline int GP_FilterPosterize(const GP_Pixmap
*src
, GP_Pixmap
*dst
,
159 GP_ProgressCallback
*callback
)
161 return GP_FilterPosterizeEx(src
, 0, 0, src
->w
, src
->h
,
162 dst
, 0, 0, steps
, callback
);
165 static inline GP_Pixmap
*
166 GP_FilterPosterizeAlloc(const GP_Pixmap
*src
, unsigned int steps
,
167 GP_ProgressCallback
*callback
)
169 return GP_FilterPosterizeExAlloc(src
, 0, 0, src
->w
, src
->h
,
174 * Inverts the pixel value, i.e. sets it to max - val.
176 int GP_FilterInvertEx(const GP_Pixmap
*const src
,
177 GP_Coord x_src
, GP_Coord y_src
,
178 GP_Size w_src
, GP_Size h_src
,
180 GP_Coord x_dst
, GP_Coord y_dst
,
181 GP_ProgressCallback
*callback
);
183 GP_Pixmap
*GP_FilterInvertExAlloc(const GP_Pixmap
*const src
,
184 GP_Coord x_src
, GP_Coord y_src
,
185 GP_Size w_src
, GP_Size h_src
,
186 GP_ProgressCallback
*callback
);
188 static inline int GP_FilterInvert(const GP_Pixmap
*src
, GP_Pixmap
*dst
,
189 GP_ProgressCallback
*callback
)
191 return GP_FilterInvertEx(src
, 0, 0, src
->w
, src
->h
,
192 dst
, 0, 0, callback
);
195 static inline GP_Pixmap
*GP_FilterInvertAlloc(const GP_Pixmap
*src
,
196 GP_ProgressCallback
*callback
)
198 return GP_FilterInvertExAlloc(src
, 0, 0, src
->w
, src
->h
, callback
);
201 #endif /* FILTERS_GP_POINT_H */