1 /**
2 * Copyright (C) 2012 hejian <hejian.he@gmail.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <libgimp/gimp.h>
19
20 #include "skin-whitening-effect.h"
21
22 void
run_effect(gint32 image_ID,WhiteningEffectType effect)23 run_effect (gint32 image_ID, WhiteningEffectType effect)
24 {
25 gint32 layer = gimp_image_get_active_layer (image_ID);
26
27 switch (effect)
28 {
29 case WHITENING_EFFECT_LITTLE_WHITENING:
30 {
31 guint8 pts[] = {
32 0.000000 * 255, 0.007843 * 255,
33 0.121569 * 255, 0.160784 * 255,
34 0.247059 * 255, 0.317647 * 255,
35 0.372549 * 255, 0.462745 * 255,
36 0.498039 * 255, 0.592157 * 255,
37 0.623529 * 255, 0.713725 * 255,
38 0.749020 * 255, 0.819608 * 255,
39 0.874510 * 255, 0.913725 * 255,
40 1.000000 * 255, 0.996078 * 255,
41 };
42 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
43 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
44 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
45 break;
46 }
47 case WHITENING_EFFECT_MODERATE_WHITENING:
48 {
49 guint8 pts[] = {
50 0.000000 * 255, 0.007843 * 255,
51 0.121569 * 255, 0.192157 * 255,
52 0.247059 * 255, 0.372549 * 255,
53 0.372549 * 255, 0.529412 * 255,
54 0.498039 * 255, 0.666667 * 255,
55 0.623529 * 255, 0.784314 * 255,
56 0.749020 * 255, 0.874510 * 255,
57 0.874510 * 255, 0.945098 * 255,
58 1.000000 * 255, 0.996078 * 255,
59 };
60 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
61 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
62 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
63 break;
64 }
65 case WHITENING_EFFECT_HIGH_WHITENING:
66 {
67 guint8 pts[] = {
68 0.000000 * 255, 0.007843 * 255,
69 0.121569 * 255, 0.223529 * 255,
70 0.247059 * 255, 0.427451 * 255,
71 0.372549 * 255, 0.600000 * 255,
72 0.498039 * 255, 0.741176 * 255,
73 0.623529 * 255, 0.854902 * 255,
74 0.749020 * 255, 0.933333 * 255,
75 0.874510 * 255, 0.980392 * 255,
76 1.000000 * 255, 0.996078 * 255,
77 };
78 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
79 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
80 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
81 break;
82 }
83 case WHITENING_EFFECT_LITTLE_PINK:
84 {
85 guint8 red_pts[] = {
86 0.000000 * 255, 0.007843 * 255,
87 0.121569 * 255, 0.160784 * 255,
88 0.247059 * 255, 0.317647 * 255,
89 0.372549 * 255, 0.462745 * 255,
90 0.498039 * 255, 0.592157 * 255,
91 0.623529 * 255, 0.713725 * 255,
92 0.749020 * 255, 0.819608 * 255,
93 0.874510 * 255, 0.913725 * 255,
94 1.000000 * 255, 0.996078 * 255,
95 };
96 guint8 pts[] = {
97 0.000000 * 255, 0.007843 * 255,
98 0.121569 * 255, 0.145098 * 255,
99 0.247059 * 255, 0.290196 * 255,
100 0.372549 * 255, 0.427451 * 255,
101 0.498039 * 255, 0.556863 * 255,
102 0.623529 * 255, 0.678431 * 255,
103 0.749020 * 255, 0.792157 * 255,
104 0.874510 * 255, 0.898039 * 255,
105 1.000000 * 255, 0.996078 * 255,
106 };
107 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
108 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
109 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
110 break;
111 }
112 case WHITENING_EFFECT_MODERATE_PINK:
113 {
114 guint8 red_pts[] = {
115 0.000000 * 255, 0.007843 * 255,
116 0.121569 * 255, 0.192157 * 255,
117 0.247059 * 255, 0.372549 * 255,
118 0.372549 * 255, 0.529412 * 255,
119 0.498039 * 255, 0.666667 * 255,
120 0.623529 * 255, 0.784314 * 255,
121 0.749020 * 255, 0.874510 * 255,
122 0.874510 * 255, 0.945098 * 255,
123 1.000000 * 255, 0.996078 * 255,
124 };
125 guint8 pts[] = {
126 0.000000 * 255, 0.007843 * 255,
127 0.121569 * 255, 0.160784 * 255,
128 0.247059 * 255, 0.321569 * 255,
129 0.372549 * 255, 0.470588 * 255,
130 0.498039 * 255, 0.600000 * 255,
131 0.623529 * 255, 0.721569 * 255,
132 0.749020 * 255, 0.827451 * 255,
133 0.874510 * 255, 0.917647 * 255,
134 1.000000 * 255, 0.996078 * 255,
135 };
136 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
137 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
138 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
139 break;
140 }
141 case WHITENING_EFFECT_HIGH_PINK:
142 {
143 guint8 red_pts[] = {
144 0.000000 * 255, 0.007843 * 255,
145 0.121569 * 255, 0.223529 * 255,
146 0.247059 * 255, 0.427451 * 255,
147 0.372549 * 255, 0.600000 * 255,
148 0.498039 * 255, 0.741176 * 255,
149 0.623529 * 255, 0.854902 * 255,
150 0.749020 * 255, 0.933333 * 255,
151 0.874510 * 255, 0.980392 * 255,
152 1.000000 * 255, 0.996078 * 255,
153 };
154 guint8 pts[] = {
155 0.000000 * 255, 0.007843 * 255,
156 0.121569 * 255, 0.180392 * 255,
157 0.247059 * 255, 0.356863 * 255,
158 0.372549 * 255, 0.513725 * 255,
159 0.498039 * 255, 0.647059 * 255,
160 0.623529 * 255, 0.764706 * 255,
161 0.749020 * 255, 0.862745 * 255,
162 0.874510 * 255, 0.937255 * 255,
163 1.000000 * 255, 0.996078 * 255,
164 };
165 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
166 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
167 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
168 break;
169 }
170 case WHITENING_EFFECT_LITTLE_FLESH:
171 {
172 guint8 red_pts[] = {
173 0.000000 * 255, 0.007843 * 255,
174 0.121569 * 255, 0.160784 * 255,
175 0.247059 * 255, 0.317647 * 255,
176 0.372549 * 255, 0.462745 * 255,
177 0.498039 * 255, 0.592157 * 255,
178 0.623529 * 255, 0.713725 * 255,
179 0.749020 * 255, 0.819608 * 255,
180 0.874510 * 255, 0.913725 * 255,
181 1.000000 * 255, 0.996078 * 255,
182 };
183 guint8 green_pts[] = {
184 0.000000 * 255, 0.007843 * 255,
185 0.121569 * 255, 0.152941 * 255,
186 0.247059 * 255, 0.301961 * 255,
187 0.372549 * 255, 0.443137 * 255,
188 0.498039 * 255, 0.576471 * 255,
189 0.623529 * 255, 0.694118 * 255,
190 0.749020 * 255, 0.807843 * 255,
191 0.874510 * 255, 0.905882 * 255,
192 1.000000 * 255, 0.996078 * 255,
193 };
194 guint8 blue_pts[] = {
195 0.000000 * 255, 0.007843 * 255,
196 0.121569 * 255, 0.145098 * 255,
197 0.247059 * 255, 0.294118 * 255,
198 0.372549 * 255, 0.435294 * 255,
199 0.498039 * 255, 0.560784 * 255,
200 0.623529 * 255, 0.686275 * 255,
201 0.749020 * 255, 0.796078 * 255,
202 0.874510 * 255, 0.901961 * 255,
203 1.000000 * 255, 0.996078 * 255,
204 };
205 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
206 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, green_pts);
207 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts);
208 break;
209 }
210 case WHITENING_EFFECT_MODERATE_FLESH:
211 {
212 guint8 red_pts[] = {
213 0.000000 * 255, 0.007843 * 255,
214 0.121569 * 255, 0.192157 * 255,
215 0.247059 * 255, 0.372549 * 255,
216 0.372549 * 255, 0.529412 * 255,
217 0.498039 * 255, 0.666667 * 255,
218 0.623529 * 255, 0.784314 * 255,
219 0.749020 * 255, 0.874510 * 255,
220 0.874510 * 255, 0.945098 * 255,
221 1.000000 * 255, 0.996078 * 255,
222 };
223 guint8 green_pts[] = {
224 0.000000 * 255, 0.007843 * 255,
225 0.121569 * 255, 0.176471 * 255,
226 0.247059 * 255, 0.345098 * 255,
227 0.372549 * 255, 0.498039 * 255,
228 0.498039 * 255, 0.635294 * 255,
229 0.623529 * 255, 0.749020 * 255,
230 0.749020 * 255, 0.850980 * 255,
231 0.874510 * 255, 0.933333 * 255,
232 1.000000 * 255, 0.996078 * 255,
233 };
234 guint8 blue_pts[] = {
235 0.000000 * 255, 0.007843 * 255,
236 0.121569 * 255, 0.164706 * 255,
237 0.247059 * 255, 0.329412 * 255,
238 0.372549 * 255, 0.482353 * 255,
239 0.498039 * 255, 0.611765 * 255,
240 0.623529 * 255, 0.733333 * 255,
241 0.749020 * 255, 0.835294 * 255,
242 0.874510 * 255, 0.921569 * 255,
243 1.000000 * 255, 0.996078 * 255,
244 };
245 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
246 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, green_pts);
247 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts);
248 break;
249 }
250 case WHITENING_EFFECT_HIGH_FLESH:
251 {
252 guint8 red_pts[] = {
253 0.000000 * 255, 0.007843 * 255,
254 0.121569 * 255, 0.223529 * 255,
255 0.247059 * 255, 0.427451 * 255,
256 0.372549 * 255, 0.600000 * 255,
257 0.498039 * 255, 0.741176 * 255,
258 0.623529 * 255, 0.854902 * 255,
259 0.749020 * 255, 0.933333 * 255,
260 0.874510 * 255, 0.980392 * 255,
261 1.000000 * 255, 0.996078 * 255,
262 };
263 guint8 green_pts[] = {
264 0.000000 * 255, 0.007843 * 255,
265 0.121569 * 255, 0.203922 * 255,
266 0.247059 * 255, 0.392157 * 255,
267 0.372549 * 255, 0.556863 * 255,
268 0.498039 * 255, 0.694118 * 255,
269 0.623529 * 255, 0.807843 * 255,
270 0.749020 * 255, 0.898039 * 255,
271 0.874510 * 255, 0.960784 * 255,
272 1.000000 * 255, 0.996078 * 255,
273 };
274 guint8 blue_pts[] = {
275 0.000000 * 255, 0.007843 * 255,
276 0.121569 * 255, 0.188235 * 255,
277 0.247059 * 255, 0.368627 * 255,
278 0.372549 * 255, 0.529412 * 255,
279 0.498039 * 255, 0.662745 * 255,
280 0.623529 * 255, 0.780392 * 255,
281 0.749020 * 255, 0.874510 * 255,
282 0.874510 * 255, 0.945098 * 255,
283 1.000000 * 255, 0.996078 * 255,
284 };
285 gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts);
286 gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, green_pts);
287 gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts);
288 break;
289 }
290 }
291 }
292