1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3  *
4  * gimpcolor_pdb.c
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 /* NOTE: This file is auto-generated by pdbgen.pl */
22 
23 #include "config.h"
24 
25 #include "gimp.h"
26 
27 
28 /**
29  * SECTION: gimpcolor
30  * @title: gimpcolor
31  * @short_description: Functions for manipulating color.
32  *
33  * Functions for manipulating color, including curves and histograms.
34  **/
35 
36 
37 /**
38  * gimp_brightness_contrast:
39  * @drawable_ID: The drawable.
40  * @brightness: Brightness adjustment.
41  * @contrast: Contrast adjustment.
42  *
43  * Deprecated: Use gimp_drawable_brightness_contrast() instead.
44  *
45  * Returns: TRUE on success.
46  **/
47 gboolean
gimp_brightness_contrast(gint32 drawable_ID,gint brightness,gint contrast)48 gimp_brightness_contrast (gint32 drawable_ID,
49                           gint   brightness,
50                           gint   contrast)
51 {
52   GimpParam *return_vals;
53   gint nreturn_vals;
54   gboolean success = TRUE;
55 
56   return_vals = gimp_run_procedure ("gimp-brightness-contrast",
57                                     &nreturn_vals,
58                                     GIMP_PDB_DRAWABLE, drawable_ID,
59                                     GIMP_PDB_INT32, brightness,
60                                     GIMP_PDB_INT32, contrast,
61                                     GIMP_PDB_END);
62 
63   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
64 
65   gimp_destroy_params (return_vals, nreturn_vals);
66 
67   return success;
68 }
69 
70 /**
71  * gimp_levels:
72  * @drawable_ID: The drawable.
73  * @channel: The channel to modify.
74  * @low_input: Intensity of lowest input.
75  * @high_input: Intensity of highest input.
76  * @gamma: Gamma adjustment factor.
77  * @low_output: Intensity of lowest output.
78  * @high_output: Intensity of highest output.
79  *
80  * Deprecated: Use gimp_drawable_levels() instead.
81  *
82  * Returns: TRUE on success.
83  **/
84 gboolean
gimp_levels(gint32 drawable_ID,GimpHistogramChannel channel,gint low_input,gint high_input,gdouble gamma,gint low_output,gint high_output)85 gimp_levels (gint32               drawable_ID,
86              GimpHistogramChannel channel,
87              gint                 low_input,
88              gint                 high_input,
89              gdouble              gamma,
90              gint                 low_output,
91              gint                 high_output)
92 {
93   GimpParam *return_vals;
94   gint nreturn_vals;
95   gboolean success = TRUE;
96 
97   return_vals = gimp_run_procedure ("gimp-levels",
98                                     &nreturn_vals,
99                                     GIMP_PDB_DRAWABLE, drawable_ID,
100                                     GIMP_PDB_INT32, channel,
101                                     GIMP_PDB_INT32, low_input,
102                                     GIMP_PDB_INT32, high_input,
103                                     GIMP_PDB_FLOAT, gamma,
104                                     GIMP_PDB_INT32, low_output,
105                                     GIMP_PDB_INT32, high_output,
106                                     GIMP_PDB_END);
107 
108   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
109 
110   gimp_destroy_params (return_vals, nreturn_vals);
111 
112   return success;
113 }
114 
115 /**
116  * gimp_levels_auto:
117  * @drawable_ID: The drawable.
118  *
119  * Deprecated: Use gimp_drawable_levels_stretch() instead.
120  *
121  * Returns: TRUE on success.
122  **/
123 gboolean
gimp_levels_auto(gint32 drawable_ID)124 gimp_levels_auto (gint32 drawable_ID)
125 {
126   GimpParam *return_vals;
127   gint nreturn_vals;
128   gboolean success = TRUE;
129 
130   return_vals = gimp_run_procedure ("gimp-levels-auto",
131                                     &nreturn_vals,
132                                     GIMP_PDB_DRAWABLE, drawable_ID,
133                                     GIMP_PDB_END);
134 
135   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
136 
137   gimp_destroy_params (return_vals, nreturn_vals);
138 
139   return success;
140 }
141 
142 /**
143  * gimp_levels_stretch:
144  * @drawable_ID: The drawable.
145  *
146  * Deprecated: Use gimp_drawable_levels_stretch() instead.
147  *
148  * Returns: TRUE on success.
149  **/
150 gboolean
gimp_levels_stretch(gint32 drawable_ID)151 gimp_levels_stretch (gint32 drawable_ID)
152 {
153   GimpParam *return_vals;
154   gint nreturn_vals;
155   gboolean success = TRUE;
156 
157   return_vals = gimp_run_procedure ("gimp-levels-stretch",
158                                     &nreturn_vals,
159                                     GIMP_PDB_DRAWABLE, drawable_ID,
160                                     GIMP_PDB_END);
161 
162   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
163 
164   gimp_destroy_params (return_vals, nreturn_vals);
165 
166   return success;
167 }
168 
169 /**
170  * gimp_posterize:
171  * @drawable_ID: The drawable.
172  * @levels: Levels of posterization.
173  *
174  * Deprecated: Use gimp_drawable_posterize() instead.
175  *
176  * Returns: TRUE on success.
177  **/
178 gboolean
gimp_posterize(gint32 drawable_ID,gint levels)179 gimp_posterize (gint32 drawable_ID,
180                 gint   levels)
181 {
182   GimpParam *return_vals;
183   gint nreturn_vals;
184   gboolean success = TRUE;
185 
186   return_vals = gimp_run_procedure ("gimp-posterize",
187                                     &nreturn_vals,
188                                     GIMP_PDB_DRAWABLE, drawable_ID,
189                                     GIMP_PDB_INT32, levels,
190                                     GIMP_PDB_END);
191 
192   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
193 
194   gimp_destroy_params (return_vals, nreturn_vals);
195 
196   return success;
197 }
198 
199 /**
200  * gimp_desaturate:
201  * @drawable_ID: The drawable.
202  *
203  * Deprecated: Use gimp_drawable_desaturate() instead.
204  *
205  * Returns: TRUE on success.
206  **/
207 gboolean
gimp_desaturate(gint32 drawable_ID)208 gimp_desaturate (gint32 drawable_ID)
209 {
210   GimpParam *return_vals;
211   gint nreturn_vals;
212   gboolean success = TRUE;
213 
214   return_vals = gimp_run_procedure ("gimp-desaturate",
215                                     &nreturn_vals,
216                                     GIMP_PDB_DRAWABLE, drawable_ID,
217                                     GIMP_PDB_END);
218 
219   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
220 
221   gimp_destroy_params (return_vals, nreturn_vals);
222 
223   return success;
224 }
225 
226 /**
227  * gimp_desaturate_full:
228  * @drawable_ID: The drawable.
229  * @desaturate_mode: The formula to use to desaturate.
230  *
231  * Deprecated: Use gimp_drawable_desaturate() instead.
232  *
233  * Returns: TRUE on success.
234  *
235  * Since: 2.4
236  **/
237 gboolean
gimp_desaturate_full(gint32 drawable_ID,GimpDesaturateMode desaturate_mode)238 gimp_desaturate_full (gint32             drawable_ID,
239                       GimpDesaturateMode desaturate_mode)
240 {
241   GimpParam *return_vals;
242   gint nreturn_vals;
243   gboolean success = TRUE;
244 
245   return_vals = gimp_run_procedure ("gimp-desaturate-full",
246                                     &nreturn_vals,
247                                     GIMP_PDB_DRAWABLE, drawable_ID,
248                                     GIMP_PDB_INT32, desaturate_mode,
249                                     GIMP_PDB_END);
250 
251   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
252 
253   gimp_destroy_params (return_vals, nreturn_vals);
254 
255   return success;
256 }
257 
258 /**
259  * gimp_equalize:
260  * @drawable_ID: The drawable.
261  * @mask_only: Equalization option.
262  *
263  * Deprecated: Use gimp_drawable_equalize() instead.
264  *
265  * Returns: TRUE on success.
266  **/
267 gboolean
gimp_equalize(gint32 drawable_ID,gboolean mask_only)268 gimp_equalize (gint32   drawable_ID,
269                gboolean mask_only)
270 {
271   GimpParam *return_vals;
272   gint nreturn_vals;
273   gboolean success = TRUE;
274 
275   return_vals = gimp_run_procedure ("gimp-equalize",
276                                     &nreturn_vals,
277                                     GIMP_PDB_DRAWABLE, drawable_ID,
278                                     GIMP_PDB_INT32, mask_only,
279                                     GIMP_PDB_END);
280 
281   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
282 
283   gimp_destroy_params (return_vals, nreturn_vals);
284 
285   return success;
286 }
287 
288 /**
289  * gimp_invert:
290  * @drawable_ID: The drawable.
291  *
292  * Deprecated: Use gimp_drawable_invert() instead.
293  *
294  * Returns: TRUE on success.
295  **/
296 gboolean
gimp_invert(gint32 drawable_ID)297 gimp_invert (gint32 drawable_ID)
298 {
299   GimpParam *return_vals;
300   gint nreturn_vals;
301   gboolean success = TRUE;
302 
303   return_vals = gimp_run_procedure ("gimp-invert",
304                                     &nreturn_vals,
305                                     GIMP_PDB_DRAWABLE, drawable_ID,
306                                     GIMP_PDB_END);
307 
308   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
309 
310   gimp_destroy_params (return_vals, nreturn_vals);
311 
312   return success;
313 }
314 
315 /**
316  * gimp_curves_spline:
317  * @drawable_ID: The drawable.
318  * @channel: The channel to modify.
319  * @num_points: The number of values in the control point array.
320  * @control_pts: The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
321  *
322  * Deprecated: Use gimp_drawable_curves_spline() instead.
323  *
324  * Returns: TRUE on success.
325  **/
326 gboolean
gimp_curves_spline(gint32 drawable_ID,GimpHistogramChannel channel,gint num_points,const guint8 * control_pts)327 gimp_curves_spline (gint32                drawable_ID,
328                     GimpHistogramChannel  channel,
329                     gint                  num_points,
330                     const guint8         *control_pts)
331 {
332   GimpParam *return_vals;
333   gint nreturn_vals;
334   gboolean success = TRUE;
335 
336   return_vals = gimp_run_procedure ("gimp-curves-spline",
337                                     &nreturn_vals,
338                                     GIMP_PDB_DRAWABLE, drawable_ID,
339                                     GIMP_PDB_INT32, channel,
340                                     GIMP_PDB_INT32, num_points,
341                                     GIMP_PDB_INT8ARRAY, control_pts,
342                                     GIMP_PDB_END);
343 
344   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
345 
346   gimp_destroy_params (return_vals, nreturn_vals);
347 
348   return success;
349 }
350 
351 /**
352  * gimp_curves_explicit:
353  * @drawable_ID: The drawable.
354  * @channel: The channel to modify.
355  * @num_bytes: The number of bytes in the new curve (always 256).
356  * @curve: The explicit curve.
357  *
358  * Deprecated: Use gimp_drawable_curves_explicit() instead.
359  *
360  * Returns: TRUE on success.
361  **/
362 gboolean
gimp_curves_explicit(gint32 drawable_ID,GimpHistogramChannel channel,gint num_bytes,const guint8 * curve)363 gimp_curves_explicit (gint32                drawable_ID,
364                       GimpHistogramChannel  channel,
365                       gint                  num_bytes,
366                       const guint8         *curve)
367 {
368   GimpParam *return_vals;
369   gint nreturn_vals;
370   gboolean success = TRUE;
371 
372   return_vals = gimp_run_procedure ("gimp-curves-explicit",
373                                     &nreturn_vals,
374                                     GIMP_PDB_DRAWABLE, drawable_ID,
375                                     GIMP_PDB_INT32, channel,
376                                     GIMP_PDB_INT32, num_bytes,
377                                     GIMP_PDB_INT8ARRAY, curve,
378                                     GIMP_PDB_END);
379 
380   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
381 
382   gimp_destroy_params (return_vals, nreturn_vals);
383 
384   return success;
385 }
386 
387 /**
388  * gimp_color_balance:
389  * @drawable_ID: The drawable.
390  * @transfer_mode: Transfer mode.
391  * @preserve_lum: Preserve luminosity values at each pixel.
392  * @cyan_red: Cyan-Red color balance.
393  * @magenta_green: Magenta-Green color balance.
394  * @yellow_blue: Yellow-Blue color balance.
395  *
396  * Modify the color balance of the specified drawable.
397  *
398  * Modify the color balance of the specified drawable. There are three
399  * axis which can be modified: cyan-red, magenta-green, and
400  * yellow-blue. Negative values increase the amount of the former,
401  * positive values increase the amount of the latter. Color balance can
402  * be controlled with the 'transfer_mode' setting, which allows
403  * shadows, mid-tones, and highlights in an image to be affected
404  * differently. The 'preserve-lum' parameter, if TRUE, ensures that the
405  * luminosity of each pixel remains fixed.
406  *
407  * Deprecated: Use gimp_drawable_color_color_balance() instead.
408  *
409  * Returns: TRUE on success.
410  **/
411 gboolean
gimp_color_balance(gint32 drawable_ID,GimpTransferMode transfer_mode,gboolean preserve_lum,gdouble cyan_red,gdouble magenta_green,gdouble yellow_blue)412 gimp_color_balance (gint32           drawable_ID,
413                     GimpTransferMode transfer_mode,
414                     gboolean         preserve_lum,
415                     gdouble          cyan_red,
416                     gdouble          magenta_green,
417                     gdouble          yellow_blue)
418 {
419   GimpParam *return_vals;
420   gint nreturn_vals;
421   gboolean success = TRUE;
422 
423   return_vals = gimp_run_procedure ("gimp-color-balance",
424                                     &nreturn_vals,
425                                     GIMP_PDB_DRAWABLE, drawable_ID,
426                                     GIMP_PDB_INT32, transfer_mode,
427                                     GIMP_PDB_INT32, preserve_lum,
428                                     GIMP_PDB_FLOAT, cyan_red,
429                                     GIMP_PDB_FLOAT, magenta_green,
430                                     GIMP_PDB_FLOAT, yellow_blue,
431                                     GIMP_PDB_END);
432 
433   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
434 
435   gimp_destroy_params (return_vals, nreturn_vals);
436 
437   return success;
438 }
439 
440 /**
441  * gimp_colorize:
442  * @drawable_ID: The drawable.
443  * @hue: Hue in degrees.
444  * @saturation: Saturation in percent.
445  * @lightness: Lightness in percent.
446  *
447  * Deprecated: Use gimp_drawable_colorize_hsl() instead.
448  *
449  * Returns: TRUE on success.
450  **/
451 gboolean
gimp_colorize(gint32 drawable_ID,gdouble hue,gdouble saturation,gdouble lightness)452 gimp_colorize (gint32  drawable_ID,
453                gdouble hue,
454                gdouble saturation,
455                gdouble lightness)
456 {
457   GimpParam *return_vals;
458   gint nreturn_vals;
459   gboolean success = TRUE;
460 
461   return_vals = gimp_run_procedure ("gimp-colorize",
462                                     &nreturn_vals,
463                                     GIMP_PDB_DRAWABLE, drawable_ID,
464                                     GIMP_PDB_FLOAT, hue,
465                                     GIMP_PDB_FLOAT, saturation,
466                                     GIMP_PDB_FLOAT, lightness,
467                                     GIMP_PDB_END);
468 
469   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
470 
471   gimp_destroy_params (return_vals, nreturn_vals);
472 
473   return success;
474 }
475 
476 /**
477  * gimp_histogram:
478  * @drawable_ID: The drawable.
479  * @channel: The channel to modify.
480  * @start_range: Start of the intensity measurement range.
481  * @end_range: End of the intensity measurement range.
482  * @mean: Mean intensity value.
483  * @std_dev: Standard deviation of intensity values.
484  * @median: Median intensity value.
485  * @pixels: Alpha-weighted pixel count for entire image.
486  * @count: Alpha-weighted pixel count for range.
487  * @percentile: Percentile that range falls under.
488  *
489  * Deprecated: Use gimp_drawable_histogram() instead.
490  *
491  * Returns: TRUE on success.
492  **/
493 gboolean
gimp_histogram(gint32 drawable_ID,GimpHistogramChannel channel,gint start_range,gint end_range,gdouble * mean,gdouble * std_dev,gdouble * median,gdouble * pixels,gdouble * count,gdouble * percentile)494 gimp_histogram (gint32                drawable_ID,
495                 GimpHistogramChannel  channel,
496                 gint                  start_range,
497                 gint                  end_range,
498                 gdouble              *mean,
499                 gdouble              *std_dev,
500                 gdouble              *median,
501                 gdouble              *pixels,
502                 gdouble              *count,
503                 gdouble              *percentile)
504 {
505   GimpParam *return_vals;
506   gint nreturn_vals;
507   gboolean success = TRUE;
508 
509   return_vals = gimp_run_procedure ("gimp-histogram",
510                                     &nreturn_vals,
511                                     GIMP_PDB_DRAWABLE, drawable_ID,
512                                     GIMP_PDB_INT32, channel,
513                                     GIMP_PDB_INT32, start_range,
514                                     GIMP_PDB_INT32, end_range,
515                                     GIMP_PDB_END);
516 
517   *mean = 0.0;
518   *std_dev = 0.0;
519   *median = 0.0;
520   *pixels = 0.0;
521   *count = 0.0;
522   *percentile = 0.0;
523 
524   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
525 
526   if (success)
527     {
528       *mean = return_vals[1].data.d_float;
529       *std_dev = return_vals[2].data.d_float;
530       *median = return_vals[3].data.d_float;
531       *pixels = return_vals[4].data.d_float;
532       *count = return_vals[5].data.d_float;
533       *percentile = return_vals[6].data.d_float;
534     }
535 
536   gimp_destroy_params (return_vals, nreturn_vals);
537 
538   return success;
539 }
540 
541 /**
542  * gimp_hue_saturation:
543  * @drawable_ID: The drawable.
544  * @hue_range: Range of affected hues.
545  * @hue_offset: Hue offset in degrees.
546  * @lightness: Lightness modification.
547  * @saturation: Saturation modification.
548  *
549  * Deprecated: Use gimp_drawable_hue_saturation() instead.
550  *
551  * Returns: TRUE on success.
552  **/
553 gboolean
gimp_hue_saturation(gint32 drawable_ID,GimpHueRange hue_range,gdouble hue_offset,gdouble lightness,gdouble saturation)554 gimp_hue_saturation (gint32       drawable_ID,
555                      GimpHueRange hue_range,
556                      gdouble      hue_offset,
557                      gdouble      lightness,
558                      gdouble      saturation)
559 {
560   GimpParam *return_vals;
561   gint nreturn_vals;
562   gboolean success = TRUE;
563 
564   return_vals = gimp_run_procedure ("gimp-hue-saturation",
565                                     &nreturn_vals,
566                                     GIMP_PDB_DRAWABLE, drawable_ID,
567                                     GIMP_PDB_INT32, hue_range,
568                                     GIMP_PDB_FLOAT, hue_offset,
569                                     GIMP_PDB_FLOAT, lightness,
570                                     GIMP_PDB_FLOAT, saturation,
571                                     GIMP_PDB_END);
572 
573   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
574 
575   gimp_destroy_params (return_vals, nreturn_vals);
576 
577   return success;
578 }
579 
580 /**
581  * gimp_threshold:
582  * @drawable_ID: The drawable.
583  * @low_threshold: The low threshold value.
584  * @high_threshold: The high threshold value.
585  *
586  * Deprecated: Use gimp_drawable_threshold() instead.
587  *
588  * Returns: TRUE on success.
589  **/
590 gboolean
gimp_threshold(gint32 drawable_ID,gint low_threshold,gint high_threshold)591 gimp_threshold (gint32 drawable_ID,
592                 gint   low_threshold,
593                 gint   high_threshold)
594 {
595   GimpParam *return_vals;
596   gint nreturn_vals;
597   gboolean success = TRUE;
598 
599   return_vals = gimp_run_procedure ("gimp-threshold",
600                                     &nreturn_vals,
601                                     GIMP_PDB_DRAWABLE, drawable_ID,
602                                     GIMP_PDB_INT32, low_threshold,
603                                     GIMP_PDB_INT32, high_threshold,
604                                     GIMP_PDB_END);
605 
606   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
607 
608   gimp_destroy_params (return_vals, nreturn_vals);
609 
610   return success;
611 }
612