gimpdrawablecolor_pdb.c 27.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 *
 * gimpdrawablecolor_pdb.c
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
18
 * <https://www.gnu.org/licenses/>.
19 20 21 22 23 24 25 26 27 28
 */

/* NOTE: This file is auto-generated by pdbgen.pl */

#include "config.h"

#include "gimp.h"


/**
29
 * SECTION: gimpdrawablecolor
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 * @title: gimpdrawablecolor
 * @short_description: Functions for manipulating a drawable's color.
 *
 * Functions for manipulating a drawable's color, including curves and
 * histograms.
 **/


/**
 * gimp_drawable_brightness_contrast:
 * @drawable_ID: The drawable.
 * @brightness: Brightness adjustment.
 * @contrast: Contrast adjustment.
 *
 * Modify brightness/contrast in the specified drawable.
 *
 * This procedures allows the brightness and contrast of the specified
 * drawable to be modified. Both 'brightness' and 'contrast' parameters
 * are defined between -0.5 and 0.5.
 *
 * Returns: TRUE on success.
 *
52
 * Since: 2.10
53 54 55 56 57 58
 **/
gboolean
gimp_drawable_brightness_contrast (gint32  drawable_ID,
                                   gdouble brightness,
                                   gdouble contrast)
{
59 60
  GimpValueArray *args;
  GimpValueArray *return_vals;
61 62
  gboolean success = TRUE;

63 64 65 66 67 68 69
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_double (gimp_value_array_index (args, 1), brightness);
  g_value_set_double (gimp_value_array_index (args, 2), contrast);
70

71 72 73
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-brightness-contrast",
                                               args);
  gimp_value_array_unref (args);
74

75 76 77
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

  return success;
}

/**
 * gimp_drawable_color_balance:
 * @drawable_ID: The drawable.
 * @transfer_mode: Transfer mode.
 * @preserve_lum: Preserve luminosity values at each pixel.
 * @cyan_red: Cyan-Red color balance.
 * @magenta_green: Magenta-Green color balance.
 * @yellow_blue: Yellow-Blue color balance.
 *
 * Modify the color balance of the specified drawable.
 *
 * Modify the color balance of the specified drawable. There are three
 * axis which can be modified: cyan-red, magenta-green, and
 * yellow-blue. Negative values increase the amount of the former,
 * positive values increase the amount of the latter. Color balance can
 * be controlled with the 'transfer_mode' setting, which allows
 * shadows, mid-tones, and highlights in an image to be affected
 * differently. The 'preserve-lum' parameter, if TRUE, ensures that the
 * luminosity of each pixel remains fixed.
 *
 * Returns: TRUE on success.
 *
104
 * Since: 2.10
105 106 107 108 109 110 111 112 113
 **/
gboolean
gimp_drawable_color_balance (gint32           drawable_ID,
                             GimpTransferMode transfer_mode,
                             gboolean         preserve_lum,
                             gdouble          cyan_red,
                             gdouble          magenta_green,
                             gdouble          yellow_blue)
{
114 115
  GimpValueArray *args;
  GimpValueArray *return_vals;
116 117
  gboolean success = TRUE;

118
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
119
                                          GIMP_TYPE_TRANSFER_MODE,
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), transfer_mode);
  g_value_set_boolean (gimp_value_array_index (args, 2), preserve_lum);
  g_value_set_double (gimp_value_array_index (args, 3), cyan_red);
  g_value_set_double (gimp_value_array_index (args, 4), magenta_green);
  g_value_set_double (gimp_value_array_index (args, 5), yellow_blue);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-color-balance",
                                               args);
  gimp_value_array_unref (args);
135

136
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
137

138
  gimp_value_array_unref (return_vals);
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158

  return success;
}

/**
 * gimp_drawable_colorize_hsl:
 * @drawable_ID: The drawable.
 * @hue: Hue in degrees.
 * @saturation: Saturation in percent.
 * @lightness: Lightness in percent.
 *
 * Render the drawable as a grayscale image seen through a colored
 * glass.
 *
 * Desaturates the drawable, then tints it with the specified color.
 * This tool is only valid on RGB color images. It will not operate on
 * grayscale drawables.
 *
 * Returns: TRUE on success.
 *
159
 * Since: 2.10
160 161 162 163 164 165 166
 **/
gboolean
gimp_drawable_colorize_hsl (gint32  drawable_ID,
                            gdouble hue,
                            gdouble saturation,
                            gdouble lightness)
{
167 168
  GimpValueArray *args;
  GimpValueArray *return_vals;
169 170
  gboolean success = TRUE;

171 172 173 174 175 176 177 178 179
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_double (gimp_value_array_index (args, 1), hue);
  g_value_set_double (gimp_value_array_index (args, 2), saturation);
  g_value_set_double (gimp_value_array_index (args, 3), lightness);
180

181 182 183
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-colorize-hsl",
                                               args);
  gimp_value_array_unref (args);
184

185 186 187
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
188 189 190 191 192 193 194 195

  return success;
}

/**
 * gimp_drawable_curves_explicit:
 * @drawable_ID: The drawable.
 * @channel: The channel to modify.
196 197
 * @num_values: The number of values in the new curve.
 * @values: The explicit curve.
198 199 200 201
 *
 * Modifies the intensity curve(s) for specified drawable.
 *
 * Modifies the intensity mapping for one channel in the specified
202 203 204 205 206
 * drawable. The channel can be either an intensity component, or the
 * value. The 'values' parameter is an array of doubles which
 * explicitly defines how each pixel value in the drawable will be
 * modified. Use the gimp_curves_spline() function to modify intensity
 * levels with Catmull Rom splines.
207 208 209
 *
 * Returns: TRUE on success.
 *
210
 * Since: 2.10
211 212 213 214
 **/
gboolean
gimp_drawable_curves_explicit (gint32                drawable_ID,
                               GimpHistogramChannel  channel,
215 216
                               gint                  num_values,
                               const gdouble        *values)
217
{
218 219
  GimpValueArray *args;
  GimpValueArray *return_vals;
220 221
  gboolean success = TRUE;

222
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
223
                                          GIMP_TYPE_HISTOGRAM_CHANNEL,
224 225 226 227 228 229 230 231 232 233 234
                                          GIMP_TYPE_INT32,
                                          GIMP_TYPE_FLOAT_ARRAY,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), channel);
  g_value_set_int (gimp_value_array_index (args, 2), num_values);
  gimp_value_set_float_array (gimp_value_array_index (args, 3), values, num_values);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-curves-explicit",
                                               args);
  gimp_value_array_unref (args);
235

236
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
237

238
  gimp_value_array_unref (return_vals);
239 240 241 242 243 244 245 246 247

  return success;
}

/**
 * gimp_drawable_curves_spline:
 * @drawable_ID: The drawable.
 * @channel: The channel to modify.
 * @num_points: The number of values in the control point array.
248
 * @points: The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
249 250 251 252
 *
 * Modifies the intensity curve(s) for specified drawable.
 *
 * Modifies the intensity mapping for one channel in the specified
253 254 255 256 257
 * drawable. The channel can be either an intensity component, or the
 * value. The 'points' parameter is an array of doubles which define a
 * set of control points which describe a Catmull Rom spline which
 * yields the final intensity curve. Use the gimp_curves_explicit()
 * function to explicitly modify intensity levels.
258 259 260
 *
 * Returns: TRUE on success.
 *
261
 * Since: 2.10
262 263 264 265 266
 **/
gboolean
gimp_drawable_curves_spline (gint32                drawable_ID,
                             GimpHistogramChannel  channel,
                             gint                  num_points,
267
                             const gdouble        *points)
268
{
269 270
  GimpValueArray *args;
  GimpValueArray *return_vals;
271 272
  gboolean success = TRUE;

273
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
274
                                          GIMP_TYPE_HISTOGRAM_CHANNEL,
275 276 277 278 279 280 281
                                          GIMP_TYPE_INT32,
                                          GIMP_TYPE_FLOAT_ARRAY,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), channel);
  g_value_set_int (gimp_value_array_index (args, 2), num_points);
  gimp_value_set_float_array (gimp_value_array_index (args, 3), points, num_points);
282

283 284 285
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-curves-spline",
                                               args);
  gimp_value_array_unref (args);
286

287 288 289
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307

  return success;
}

/**
 * gimp_drawable_desaturate:
 * @drawable_ID: The drawable.
 * @desaturate_mode: The formula to use to desaturate.
 *
 * Desaturate the contents of the specified drawable, with the
 * specified formula.
 *
 * This procedure desaturates the contents of the specified drawable,
 * with the specified formula. This procedure only works on drawables
 * of type RGB color.
 *
 * Returns: TRUE on success.
 *
308
 * Since: 2.10
309 310 311 312 313
 **/
gboolean
gimp_drawable_desaturate (gint32             drawable_ID,
                          GimpDesaturateMode desaturate_mode)
{
314 315
  GimpValueArray *args;
  GimpValueArray *return_vals;
316 317
  gboolean success = TRUE;

318
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
319
                                          GIMP_TYPE_DESATURATE_MODE,
320 321 322 323 324 325 326
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), desaturate_mode);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-desaturate",
                                               args);
  gimp_value_array_unref (args);
327

328
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
329

330
  gimp_value_array_unref (return_vals);
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351

  return success;
}

/**
 * gimp_drawable_equalize:
 * @drawable_ID: The drawable.
 * @mask_only: Equalization option.
 *
 * Equalize the contents of the specified drawable.
 *
 * This procedure equalizes the contents of the specified drawable.
 * Each intensity channel is equalized independently. The equalized
 * intensity is given as inten' = (255 - inten). The 'mask_only' option
 * specifies whether to adjust only the area of the image within the
 * selection bounds, or the entire image based on the histogram of the
 * selected area. If there is no selection, the entire image is
 * adjusted based on the histogram for the entire image.
 *
 * Returns: TRUE on success.
 *
352
 * Since: 2.10
353 354 355 356 357
 **/
gboolean
gimp_drawable_equalize (gint32   drawable_ID,
                        gboolean mask_only)
{
358 359
  GimpValueArray *args;
  GimpValueArray *return_vals;
360 361
  gboolean success = TRUE;

362 363 364 365 366
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_boolean (gimp_value_array_index (args, 1), mask_only);
367

368 369 370
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-equalize",
                                               args);
  gimp_value_array_unref (args);
371

372 373 374
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
375 376 377 378 379 380 381

  return success;
}

/**
 * gimp_drawable_histogram:
 * @drawable_ID: The drawable.
382
 * @channel: The channel to query.
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
 * @start_range: Start of the intensity measurement range.
 * @end_range: End of the intensity measurement range.
 * @mean: Mean intensity value.
 * @std_dev: Standard deviation of intensity values.
 * @median: Median intensity value.
 * @pixels: Alpha-weighted pixel count for entire image.
 * @count: Alpha-weighted pixel count for range.
 * @percentile: Percentile that range falls under.
 *
 * Returns information on the intensity histogram for the specified
 * drawable.
 *
 * This tool makes it possible to gather information about the
 * intensity histogram of a drawable. A channel to examine is first
 * specified. This can be either value, red, green, or blue, depending
 * on whether the drawable is of type color or grayscale. Second, a
399 400 401 402 403
 * range of intensities are specified. The gimp_drawable_histogram()
 * function returns statistics based on the pixels in the drawable that
 * fall under this range of values. Mean, standard deviation, median,
 * number of pixels, and percentile are all returned. Additionally, the
 * total count of pixels in the image is returned. Counts of pixels are
404 405 406 407
 * weighted by any associated alpha values and by the current selection
 * mask. That is, pixels that lie outside an active selection mask will
 * not be counted. Similarly, pixels with transparent alpha values will
 * not be counted. The returned mean, std_dev and median are in the
408
 * range (0..255) for 8-bit images or if the plug-in is not
409 410 411 412
 * precision-aware, and in the range (0.0..1.0) otherwise.
 *
 * Returns: TRUE on success.
 *
413
 * Since: 2.10
414 415 416 417
 **/
gboolean
gimp_drawable_histogram (gint32                drawable_ID,
                         GimpHistogramChannel  channel,
418 419
                         gdouble               start_range,
                         gdouble               end_range,
420 421 422 423 424 425 426
                         gdouble              *mean,
                         gdouble              *std_dev,
                         gdouble              *median,
                         gdouble              *pixels,
                         gdouble              *count,
                         gdouble              *percentile)
{
427 428
  GimpValueArray *args;
  GimpValueArray *return_vals;
429 430
  gboolean success = TRUE;

431
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
432
                                          GIMP_TYPE_HISTOGRAM_CHANNEL,
433 434 435 436 437 438 439 440 441 442 443
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), channel);
  g_value_set_double (gimp_value_array_index (args, 2), start_range);
  g_value_set_double (gimp_value_array_index (args, 3), end_range);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-histogram",
                                               args);
  gimp_value_array_unref (args);
444 445 446 447 448 449 450 451

  *mean = 0.0;
  *std_dev = 0.0;
  *median = 0.0;
  *pixels = 0.0;
  *count = 0.0;
  *percentile = 0.0;

452
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
453 454 455

  if (success)
    {
456 457 458 459 460 461
      *mean = g_value_get_double (gimp_value_array_index (return_vals, 1));
      *std_dev = g_value_get_double (gimp_value_array_index (return_vals, 2));
      *median = g_value_get_double (gimp_value_array_index (return_vals, 3));
      *pixels = g_value_get_double (gimp_value_array_index (return_vals, 4));
      *count = g_value_get_double (gimp_value_array_index (return_vals, 5));
      *percentile = g_value_get_double (gimp_value_array_index (return_vals, 6));
462 463
    }

464
  gimp_value_array_unref (return_vals);
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487

  return success;
}

/**
 * gimp_drawable_hue_saturation:
 * @drawable_ID: The drawable.
 * @hue_range: Range of affected hues.
 * @hue_offset: Hue offset in degrees.
 * @lightness: Lightness modification.
 * @saturation: Saturation modification.
 * @overlap: Overlap other hue channels.
 *
 * Modify hue, lightness, and saturation in the specified drawable.
 *
 * This procedure allows the hue, lightness, and saturation in the
 * specified drawable to be modified. The 'hue-range' parameter
 * provides the capability to limit range of affected hues. The
 * 'overlap' parameter provides blending into neighboring hue channels
 * when rendering.
 *
 * Returns: TRUE on success.
 *
488
 * Since: 2.10
489 490 491 492 493 494 495 496 497
 **/
gboolean
gimp_drawable_hue_saturation (gint32       drawable_ID,
                              GimpHueRange hue_range,
                              gdouble      hue_offset,
                              gdouble      lightness,
                              gdouble      saturation,
                              gdouble      overlap)
{
498 499
  GimpValueArray *args;
  GimpValueArray *return_vals;
500 501
  gboolean success = TRUE;

502
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
503
                                          GIMP_TYPE_HUE_RANGE,
504 505 506 507 508 509 510 511 512 513 514
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), hue_range);
  g_value_set_double (gimp_value_array_index (args, 2), hue_offset);
  g_value_set_double (gimp_value_array_index (args, 3), lightness);
  g_value_set_double (gimp_value_array_index (args, 4), saturation);
  g_value_set_double (gimp_value_array_index (args, 5), overlap);
515

516 517 518
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-hue-saturation",
                                               args);
  gimp_value_array_unref (args);
519

520 521 522
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
523 524 525 526 527

  return success;
}

/**
528
 * gimp_drawable_invert:
529
 * @drawable_ID: The drawable.
530
 * @linear: Whether to invert in linear space.
531
 *
532
 * Invert the contents of the specified drawable.
533 534 535
 *
 * This procedure inverts the contents of the specified drawable. Each
 * intensity channel is inverted independently. The inverted intensity
536 537
 * is given as inten' = (255 - inten). If 'linear' is TRUE, the
 * drawable is inverted in linear space.
538 539 540
 *
 * Returns: TRUE on success.
 *
541
 * Since: 2.10
542 543
 **/
gboolean
544 545
gimp_drawable_invert (gint32   drawable_ID,
                      gboolean linear)
546
{
547 548
  GimpValueArray *args;
  GimpValueArray *return_vals;
549 550
  gboolean success = TRUE;

551 552 553 554 555 556 557 558 559
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_boolean (gimp_value_array_index (args, 1), linear);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-invert",
                                               args);
  gimp_value_array_unref (args);
560

561
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
562

563
  gimp_value_array_unref (return_vals);
564 565 566 567 568 569 570 571 572 573

  return success;
}

/**
 * gimp_drawable_levels:
 * @drawable_ID: The drawable.
 * @channel: The channel to modify.
 * @low_input: Intensity of lowest input.
 * @high_input: Intensity of highest input.
574
 * @clamp_input: Clamp input values before applying output levels.
575
 * @gamma: Gamma adjustment factor.
576 577
 * @low_output: Intensity of lowest output.
 * @high_output: Intensity of highest output.
578
 * @clamp_output: Clamp final output values.
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
 *
 * Modifies intensity levels in the specified drawable.
 *
 * This tool allows intensity levels in the specified drawable to be
 * remapped according to a set of parameters. The low/high input levels
 * specify an initial mapping from the source intensities. The gamma
 * value determines how intensities between the low and high input
 * intensities are interpolated. A gamma value of 1.0 results in a
 * linear interpolation. Higher gamma values result in more high-level
 * intensities. Lower gamma values result in more low-level
 * intensities. The low/high output levels constrain the final
 * intensity mapping--that is, no final intensity will be lower than
 * the low output level and no final intensity will be higher than the
 * high output level. This tool is only valid on RGB color and
 * grayscale images.
 *
 * Returns: TRUE on success.
 *
597
 * Since: 2.10
598 599 600 601 602 603
 **/
gboolean
gimp_drawable_levels (gint32               drawable_ID,
                      GimpHistogramChannel channel,
                      gdouble              low_input,
                      gdouble              high_input,
604
                      gboolean             clamp_input,
605 606
                      gdouble              gamma,
                      gdouble              low_output,
607 608
                      gdouble              high_output,
                      gboolean             clamp_output)
609
{
610 611
  GimpValueArray *args;
  GimpValueArray *return_vals;
612 613
  gboolean success = TRUE;

614
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
615
                                          GIMP_TYPE_HISTOGRAM_CHANNEL,
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_BOOLEAN,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), channel);
  g_value_set_double (gimp_value_array_index (args, 2), low_input);
  g_value_set_double (gimp_value_array_index (args, 3), high_input);
  g_value_set_boolean (gimp_value_array_index (args, 4), clamp_input);
  g_value_set_double (gimp_value_array_index (args, 5), gamma);
  g_value_set_double (gimp_value_array_index (args, 6), low_output);
  g_value_set_double (gimp_value_array_index (args, 7), high_output);
  g_value_set_boolean (gimp_value_array_index (args, 8), clamp_output);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-levels",
                                               args);
  gimp_value_array_unref (args);

  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656

  return success;
}

/**
 * gimp_drawable_levels_stretch:
 * @drawable_ID: The drawable.
 *
 * Automatically modifies intensity levels in the specified drawable.
 *
 * This procedure allows intensity levels in the specified drawable to
 * be remapped according to a set of guessed parameters. It is
 * equivalent to clicking the \"Auto\" button in the Levels tool.
 *
 * Returns: TRUE on success.
 *
657
 * Since: 2.10
658 659 660 661
 **/
gboolean
gimp_drawable_levels_stretch (gint32 drawable_ID)
{
662 663
  GimpValueArray *args;
  GimpValueArray *return_vals;
664 665
  gboolean success = TRUE;

666 667 668
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
669

670 671 672
  return_vals = gimp_run_procedure_with_array ("gimp-drawable-levels-stretch",
                                               args);
  gimp_value_array_unref (args);
673

674 675 676
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;

  gimp_value_array_unref (return_vals);
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692

  return success;
}

/**
 * gimp_drawable_posterize:
 * @drawable_ID: The drawable.
 * @levels: Levels of posterization.
 *
 * Posterize the specified drawable.
 *
 * This procedures reduces the number of shades allows in each
 * intensity channel to the specified 'levels' parameter.
 *
 * Returns: TRUE on success.
 *
693
 * Since: 2.10
694 695 696 697 698
 **/
gboolean
gimp_drawable_posterize (gint32 drawable_ID,
                         gint   levels)
{
699 700
  GimpValueArray *args;
  GimpValueArray *return_vals;
701 702
  gboolean success = TRUE;

703 704 705 706 707 708 709 710 711
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
                                          GIMP_TYPE_INT32,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_int (gimp_value_array_index (args, 1), levels);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-posterize",
                                               args);
  gimp_value_array_unref (args);
712

713
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
714

715
  gimp_value_array_unref (return_vals);
716 717 718 719 720 721 722

  return success;
}

/**
 * gimp_drawable_threshold:
 * @drawable_ID: The drawable.
723
 * @channel: The channel to base the threshold on.
724 725 726 727 728 729 730
 * @low_threshold: The low threshold value.
 * @high_threshold: The high threshold value.
 *
 * Threshold the specified drawable.
 *
 * This procedures generates a threshold map of the specified drawable.
 * All pixels between the values of 'low_threshold' and
731 732
 * 'high_threshold', on the scale of 'channel' are replaced with white,
 * and all other pixels with black.
733 734 735
 *
 * Returns: TRUE on success.
 *
736
 * Since: 2.10
737 738
 **/
gboolean
739 740 741 742
gimp_drawable_threshold (gint32               drawable_ID,
                         GimpHistogramChannel channel,
                         gdouble              low_threshold,
                         gdouble              high_threshold)
743
{
744 745
  GimpValueArray *args;
  GimpValueArray *return_vals;
746 747
  gboolean success = TRUE;

748
  args = gimp_value_array_new_from_types (GIMP_TYPE_DRAWABLE_ID,
749
                                          GIMP_TYPE_HISTOGRAM_CHANNEL,
750 751 752 753 754 755 756 757 758 759 760
                                          G_TYPE_DOUBLE,
                                          G_TYPE_DOUBLE,
                                          G_TYPE_NONE);
  gimp_value_set_drawable_id (gimp_value_array_index (args, 0), drawable_ID);
  g_value_set_enum (gimp_value_array_index (args, 1), channel);
  g_value_set_double (gimp_value_array_index (args, 2), low_threshold);
  g_value_set_double (gimp_value_array_index (args, 3), high_threshold);

  return_vals = gimp_run_procedure_with_array ("gimp-drawable-threshold",
                                               args);
  gimp_value_array_unref (args);
761

762
  success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS;
763

764
  gimp_value_array_unref (return_vals);
765 766 767

  return success;
}