~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/pdb/color_cmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GIMP - The GNU Image Manipulation Program
2
 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
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 2 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, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
 */
18
 
 
19
 
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
 
24
 
#include <glib-object.h>
25
 
 
26
 
#include "pdb-types.h"
27
 
#include "gimppdb.h"
28
 
#include "gimpprocedure.h"
29
 
#include "core/gimpparamspecs.h"
30
 
 
31
 
#include "base/color-balance.h"
32
 
#include "base/colorize.h"
33
 
#include "base/curves.h"
34
 
#include "base/gimphistogram.h"
35
 
#include "base/gimplut.h"
36
 
#include "base/hue-saturation.h"
37
 
#include "base/levels.h"
38
 
#include "base/lut-funcs.h"
39
 
#include "base/pixel-processor.h"
40
 
#include "base/pixel-region.h"
41
 
#include "base/threshold.h"
42
 
#include "core/gimp.h"
43
 
#include "core/gimpdrawable-desaturate.h"
44
 
#include "core/gimpdrawable-equalize.h"
45
 
#include "core/gimpdrawable-histogram.h"
46
 
#include "core/gimpdrawable-invert.h"
47
 
#include "core/gimpdrawable-levels.h"
48
 
#include "core/gimpdrawable.h"
49
 
#include "core/gimpimage.h"
50
 
#include "gimp-intl.h"
51
 
 
52
 
#include "internal_procs.h"
53
 
 
54
 
 
55
 
static GValueArray *
56
 
brightness_contrast_invoker (GimpProcedure     *procedure,
57
 
                             Gimp              *gimp,
58
 
                             GimpContext       *context,
59
 
                             GimpProgress      *progress,
60
 
                             const GValueArray *args)
61
 
{
62
 
  gboolean success = TRUE;
63
 
  GimpDrawable *drawable;
64
 
  gint32 brightness;
65
 
  gint32 contrast;
66
 
 
67
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
68
 
  brightness = g_value_get_int (&args->values[1]);
69
 
  contrast = g_value_get_int (&args->values[2]);
70
 
 
71
 
  if (success)
72
 
    {
73
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
74
 
          gimp_drawable_is_indexed (drawable))
75
 
        success = FALSE;
76
 
 
77
 
      if (success)
78
 
        {
79
 
          gint x, y, width, height;
80
 
 
81
 
          /* The application should occur only within selection bounds */
82
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
83
 
            {
84
 
              GimpLut     *lut;
85
 
              PixelRegion  srcPR, destPR;
86
 
 
87
 
              lut = brightness_contrast_lut_new (brightness / 255.0,
88
 
                                                 contrast / 127.0,
89
 
                                                 gimp_drawable_bytes (drawable));
90
 
 
91
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
92
 
                                 x, y, width, height, FALSE);
93
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
94
 
                                 x, y, width, height, TRUE);
95
 
 
96
 
              pixel_regions_process_parallel ((PixelProcessorFunc)
97
 
                                              gimp_lut_process,
98
 
                                              lut, 2, &srcPR, &destPR);
99
 
 
100
 
              gimp_lut_free (lut);
101
 
 
102
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast"));
103
 
              gimp_drawable_update (drawable, x, y, width, height);
104
 
            }
105
 
        }
106
 
    }
107
 
 
108
 
  return gimp_procedure_get_return_values (procedure, success);
109
 
}
110
 
 
111
 
static GValueArray *
112
 
levels_invoker (GimpProcedure     *procedure,
113
 
                Gimp              *gimp,
114
 
                GimpContext       *context,
115
 
                GimpProgress      *progress,
116
 
                const GValueArray *args)
117
 
{
118
 
  gboolean success = TRUE;
119
 
  GimpDrawable *drawable;
120
 
  gint32 channel;
121
 
  gint32 low_input;
122
 
  gint32 high_input;
123
 
  gdouble gamma;
124
 
  gint32 low_output;
125
 
  gint32 high_output;
126
 
 
127
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
128
 
  channel = g_value_get_enum (&args->values[1]);
129
 
  low_input = g_value_get_int (&args->values[2]);
130
 
  high_input = g_value_get_int (&args->values[3]);
131
 
  gamma = g_value_get_double (&args->values[4]);
132
 
  low_output = g_value_get_int (&args->values[5]);
133
 
  high_output = g_value_get_int (&args->values[6]);
134
 
 
135
 
  if (success)
136
 
    {
137
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
138
 
          gimp_drawable_is_indexed (drawable) ||
139
 
          (! gimp_drawable_has_alpha (drawable) &&
140
 
           channel == GIMP_HISTOGRAM_ALPHA) ||
141
 
          (gimp_drawable_is_gray (drawable) &&
142
 
           channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
143
 
        success = FALSE;
144
 
 
145
 
      if (success)
146
 
        gimp_drawable_levels (drawable, context,
147
 
                              channel,
148
 
                              low_input, high_input,
149
 
                              gamma,
150
 
                              low_output, high_output);
151
 
    }
152
 
 
153
 
  return gimp_procedure_get_return_values (procedure, success);
154
 
}
155
 
 
156
 
static GValueArray *
157
 
levels_auto_invoker (GimpProcedure     *procedure,
158
 
                     Gimp              *gimp,
159
 
                     GimpContext       *context,
160
 
                     GimpProgress      *progress,
161
 
                     const GValueArray *args)
162
 
{
163
 
  gboolean success = TRUE;
164
 
  GimpDrawable *drawable;
165
 
 
166
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
167
 
 
168
 
  if (success)
169
 
    {
170
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
171
 
          gimp_drawable_is_indexed (drawable))
172
 
        success = FALSE;
173
 
 
174
 
      if (success)
175
 
        gimp_drawable_levels_stretch (drawable, context);
176
 
    }
177
 
 
178
 
  return gimp_procedure_get_return_values (procedure, success);
179
 
}
180
 
 
181
 
static GValueArray *
182
 
levels_stretch_invoker (GimpProcedure     *procedure,
183
 
                        Gimp              *gimp,
184
 
                        GimpContext       *context,
185
 
                        GimpProgress      *progress,
186
 
                        const GValueArray *args)
187
 
{
188
 
  gboolean success = TRUE;
189
 
  GimpDrawable *drawable;
190
 
 
191
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
192
 
 
193
 
  if (success)
194
 
    {
195
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
196
 
          gimp_drawable_is_indexed (drawable))
197
 
        success = FALSE;
198
 
 
199
 
      if (success)
200
 
        gimp_drawable_levels_stretch (drawable, context);
201
 
    }
202
 
 
203
 
  return gimp_procedure_get_return_values (procedure, success);
204
 
}
205
 
 
206
 
static GValueArray *
207
 
posterize_invoker (GimpProcedure     *procedure,
208
 
                   Gimp              *gimp,
209
 
                   GimpContext       *context,
210
 
                   GimpProgress      *progress,
211
 
                   const GValueArray *args)
212
 
{
213
 
  gboolean success = TRUE;
214
 
  GimpDrawable *drawable;
215
 
  gint32 levels;
216
 
 
217
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
218
 
  levels = g_value_get_int (&args->values[1]);
219
 
 
220
 
  if (success)
221
 
    {
222
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
223
 
          gimp_drawable_is_indexed (drawable))
224
 
        success = FALSE;
225
 
 
226
 
      if (success)
227
 
        {
228
 
          gint x, y, width, height;
229
 
 
230
 
          /* The application should occur only within selection bounds */
231
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
232
 
            {
233
 
              GimpLut     *lut;
234
 
              PixelRegion  srcPR, destPR;
235
 
 
236
 
              lut = posterize_lut_new (levels, gimp_drawable_bytes (drawable));
237
 
 
238
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
239
 
                                 x, y, width, height, FALSE);
240
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
241
 
                                 x, y, width, height, TRUE);
242
 
 
243
 
              pixel_regions_process_parallel ((PixelProcessorFunc)
244
 
                                              gimp_lut_process,
245
 
                                              lut, 2, &srcPR, &destPR);
246
 
 
247
 
              gimp_lut_free (lut);
248
 
 
249
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize"));
250
 
              gimp_drawable_update (drawable, x, y, width, height);
251
 
            }
252
 
        }
253
 
    }
254
 
 
255
 
  return gimp_procedure_get_return_values (procedure, success);
256
 
}
257
 
 
258
 
static GValueArray *
259
 
desaturate_invoker (GimpProcedure     *procedure,
260
 
                    Gimp              *gimp,
261
 
                    GimpContext       *context,
262
 
                    GimpProgress      *progress,
263
 
                    const GValueArray *args)
264
 
{
265
 
  gboolean success = TRUE;
266
 
  GimpDrawable *drawable;
267
 
 
268
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
269
 
 
270
 
  if (success)
271
 
    {
272
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
273
 
          ! gimp_drawable_is_rgb (drawable))
274
 
        success = FALSE;
275
 
 
276
 
      if (success)
277
 
        gimp_drawable_desaturate (drawable, GIMP_DESATURATE_LIGHTNESS);
278
 
    }
279
 
 
280
 
  return gimp_procedure_get_return_values (procedure, success);
281
 
}
282
 
 
283
 
static GValueArray *
284
 
desaturate_full_invoker (GimpProcedure     *procedure,
285
 
                         Gimp              *gimp,
286
 
                         GimpContext       *context,
287
 
                         GimpProgress      *progress,
288
 
                         const GValueArray *args)
289
 
{
290
 
  gboolean success = TRUE;
291
 
  GimpDrawable *drawable;
292
 
  gint32 desaturate_mode;
293
 
 
294
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
295
 
  desaturate_mode = g_value_get_enum (&args->values[1]);
296
 
 
297
 
  if (success)
298
 
    {
299
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
300
 
          ! gimp_drawable_is_rgb (drawable))
301
 
        success = FALSE;
302
 
 
303
 
      if (success)
304
 
        gimp_drawable_desaturate (drawable, desaturate_mode);
305
 
    }
306
 
 
307
 
  return gimp_procedure_get_return_values (procedure, success);
308
 
}
309
 
 
310
 
static GValueArray *
311
 
equalize_invoker (GimpProcedure     *procedure,
312
 
                  Gimp              *gimp,
313
 
                  GimpContext       *context,
314
 
                  GimpProgress      *progress,
315
 
                  const GValueArray *args)
316
 
{
317
 
  gboolean success = TRUE;
318
 
  GimpDrawable *drawable;
319
 
  gboolean mask_only;
320
 
 
321
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
322
 
  mask_only = g_value_get_boolean (&args->values[1]);
323
 
 
324
 
  if (success)
325
 
    {
326
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
327
 
          gimp_drawable_is_indexed (drawable))
328
 
        success = FALSE;
329
 
 
330
 
      if (success)
331
 
        gimp_drawable_equalize (drawable, mask_only);
332
 
    }
333
 
 
334
 
  return gimp_procedure_get_return_values (procedure, success);
335
 
}
336
 
 
337
 
static GValueArray *
338
 
invert_invoker (GimpProcedure     *procedure,
339
 
                Gimp              *gimp,
340
 
                GimpContext       *context,
341
 
                GimpProgress      *progress,
342
 
                const GValueArray *args)
343
 
{
344
 
  gboolean success = TRUE;
345
 
  GimpDrawable *drawable;
346
 
 
347
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
348
 
 
349
 
  if (success)
350
 
    {
351
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
352
 
          gimp_drawable_is_indexed (drawable))
353
 
        success = FALSE;
354
 
 
355
 
      if (success)
356
 
        gimp_drawable_invert (drawable);
357
 
    }
358
 
 
359
 
  return gimp_procedure_get_return_values (procedure, success);
360
 
}
361
 
 
362
 
static GValueArray *
363
 
curves_spline_invoker (GimpProcedure     *procedure,
364
 
                       Gimp              *gimp,
365
 
                       GimpContext       *context,
366
 
                       GimpProgress      *progress,
367
 
                       const GValueArray *args)
368
 
{
369
 
  gboolean success = TRUE;
370
 
  GimpDrawable *drawable;
371
 
  gint32 channel;
372
 
  gint32 num_points;
373
 
  const guint8 *control_pts;
374
 
 
375
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
376
 
  channel = g_value_get_enum (&args->values[1]);
377
 
  num_points = g_value_get_int (&args->values[2]);
378
 
  control_pts = gimp_value_get_int8array (&args->values[3]);
379
 
 
380
 
  if (success)
381
 
    {
382
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
383
 
          gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
384
 
          (! gimp_drawable_has_alpha (drawable) &&
385
 
           channel == GIMP_HISTOGRAM_ALPHA) ||
386
 
          (gimp_drawable_is_gray (drawable) &&
387
 
           channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
388
 
        success = FALSE;
389
 
 
390
 
      if (success)
391
 
        {
392
 
          gint x, y, width, height;
393
 
 
394
 
          /* The application should occur only within selection bounds */
395
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
396
 
            {
397
 
              Curves       c;
398
 
              gint         j;
399
 
              PixelRegion  srcPR, destPR;
400
 
              GimpLut     *lut;
401
 
 
402
 
              /* FIXME: hack */
403
 
              if (gimp_drawable_is_gray (drawable) &&
404
 
                  channel == GIMP_HISTOGRAM_ALPHA)
405
 
                channel = 1;
406
 
 
407
 
              lut = gimp_lut_new ();
408
 
 
409
 
              curves_init (&c);
410
 
 
411
 
              /*  unset the last point  */
412
 
              c.points[channel][CURVES_NUM_POINTS - 1][0] = -1;
413
 
              c.points[channel][CURVES_NUM_POINTS - 1][1] = -1;
414
 
 
415
 
              for (j = 0; j < num_points / 2; j++)
416
 
                {
417
 
                  c.points[channel][j][0] = control_pts[j * 2];
418
 
                  c.points[channel][j][1] = control_pts[j * 2 + 1];
419
 
                }
420
 
 
421
 
              curves_calculate_curve (&c, channel);
422
 
 
423
 
              gimp_lut_setup (lut,
424
 
                              (GimpLutFunc) curves_lut_func,
425
 
                              &c,
426
 
                              gimp_drawable_bytes (drawable));
427
 
 
428
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
429
 
                                 x, y, width, height, FALSE);
430
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
431
 
                                 x, y, width, height, TRUE);
432
 
 
433
 
              pixel_regions_process_parallel ((PixelProcessorFunc)
434
 
                                              gimp_lut_process,
435
 
                                              lut, 2, &srcPR, &destPR);
436
 
 
437
 
              gimp_lut_free (lut);
438
 
 
439
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
440
 
              gimp_drawable_update (drawable, x, y, width, height);
441
 
            }
442
 
        }
443
 
    }
444
 
 
445
 
  return gimp_procedure_get_return_values (procedure, success);
446
 
}
447
 
 
448
 
static GValueArray *
449
 
curves_explicit_invoker (GimpProcedure     *procedure,
450
 
                         Gimp              *gimp,
451
 
                         GimpContext       *context,
452
 
                         GimpProgress      *progress,
453
 
                         const GValueArray *args)
454
 
{
455
 
  gboolean success = TRUE;
456
 
  GimpDrawable *drawable;
457
 
  gint32 channel;
458
 
  gint32 num_bytes;
459
 
  const guint8 *curve;
460
 
 
461
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
462
 
  channel = g_value_get_enum (&args->values[1]);
463
 
  num_bytes = g_value_get_int (&args->values[2]);
464
 
  curve = gimp_value_get_int8array (&args->values[3]);
465
 
 
466
 
  if (success)
467
 
    {
468
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
469
 
          gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
470
 
          (! gimp_drawable_has_alpha (drawable) &&
471
 
           channel == GIMP_HISTOGRAM_ALPHA) ||
472
 
          (gimp_drawable_is_gray (drawable) &&
473
 
           channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
474
 
        success = FALSE;
475
 
 
476
 
      if (success)
477
 
        {
478
 
          gint x, y, width, height;
479
 
 
480
 
          /* The application should occur only within selection bounds */
481
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
482
 
            {
483
 
              Curves       c;
484
 
              gint         j;
485
 
              PixelRegion  srcPR, destPR;
486
 
              GimpLut     *lut;
487
 
 
488
 
              /* FIXME: hack */
489
 
              if (gimp_drawable_is_gray (drawable) &&
490
 
                  channel == GIMP_HISTOGRAM_ALPHA)
491
 
                channel = 1;
492
 
 
493
 
              lut = gimp_lut_new ();
494
 
 
495
 
              curves_init (&c);
496
 
 
497
 
              for (j = 0; j < 256; j++)
498
 
                c.curve[channel][j] = curve[j];
499
 
 
500
 
              gimp_lut_setup (lut,
501
 
                              (GimpLutFunc) curves_lut_func,
502
 
                              &c,
503
 
                              gimp_drawable_bytes (drawable));
504
 
 
505
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
506
 
                                 x, y, width, height, FALSE);
507
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
508
 
                                 x, y, width, height, TRUE);
509
 
 
510
 
              pixel_regions_process_parallel ((PixelProcessorFunc)
511
 
                                              gimp_lut_process,
512
 
                                              lut, 2, &srcPR, &destPR);
513
 
 
514
 
              gimp_lut_free (lut);
515
 
 
516
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
517
 
              gimp_drawable_update (drawable, x, y, width, height);
518
 
            }
519
 
        }
520
 
    }
521
 
 
522
 
  return gimp_procedure_get_return_values (procedure, success);
523
 
}
524
 
 
525
 
static GValueArray *
526
 
color_balance_invoker (GimpProcedure     *procedure,
527
 
                       Gimp              *gimp,
528
 
                       GimpContext       *context,
529
 
                       GimpProgress      *progress,
530
 
                       const GValueArray *args)
531
 
{
532
 
  gboolean success = TRUE;
533
 
  GimpDrawable *drawable;
534
 
  gint32 transfer_mode;
535
 
  gboolean preserve_lum;
536
 
  gdouble cyan_red;
537
 
  gdouble magenta_green;
538
 
  gdouble yellow_blue;
539
 
 
540
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
541
 
  transfer_mode = g_value_get_enum (&args->values[1]);
542
 
  preserve_lum = g_value_get_boolean (&args->values[2]);
543
 
  cyan_red = g_value_get_double (&args->values[3]);
544
 
  magenta_green = g_value_get_double (&args->values[4]);
545
 
  yellow_blue = g_value_get_double (&args->values[5]);
546
 
 
547
 
  if (success)
548
 
    {
549
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
550
 
          gimp_drawable_is_indexed (drawable))
551
 
        success = FALSE;
552
 
 
553
 
      if (success)
554
 
        {
555
 
          gint x, y, width, height;
556
 
 
557
 
          /* The application should occur only within selection bounds */
558
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
559
 
            {
560
 
              ColorBalance  cb;
561
 
              PixelRegion   srcPR, destPR;
562
 
 
563
 
              color_balance_init (&cb);
564
 
 
565
 
              cb.preserve_luminosity = preserve_lum;
566
 
 
567
 
              cb.cyan_red[transfer_mode]      = cyan_red;
568
 
              cb.magenta_green[transfer_mode] = magenta_green;
569
 
              cb.yellow_blue[transfer_mode]   = yellow_blue;
570
 
 
571
 
              color_balance_create_lookup_tables (&cb);
572
 
 
573
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
574
 
                                 x, y, width, height, FALSE);
575
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
576
 
                                 x, y, width, height, TRUE);
577
 
 
578
 
              pixel_regions_process_parallel ((PixelProcessorFunc) color_balance,
579
 
                                              &cb, 2, &srcPR, &destPR);
580
 
 
581
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance"));
582
 
              gimp_drawable_update (drawable, x, y, width, height);
583
 
            }
584
 
        }
585
 
    }
586
 
 
587
 
  return gimp_procedure_get_return_values (procedure, success);
588
 
}
589
 
 
590
 
static GValueArray *
591
 
colorize_invoker (GimpProcedure     *procedure,
592
 
                  Gimp              *gimp,
593
 
                  GimpContext       *context,
594
 
                  GimpProgress      *progress,
595
 
                  const GValueArray *args)
596
 
{
597
 
  gboolean success = TRUE;
598
 
  GimpDrawable *drawable;
599
 
  gdouble hue;
600
 
  gdouble saturation;
601
 
  gdouble lightness;
602
 
 
603
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
604
 
  hue = g_value_get_double (&args->values[1]);
605
 
  saturation = g_value_get_double (&args->values[2]);
606
 
  lightness = g_value_get_double (&args->values[3]);
607
 
 
608
 
  if (success)
609
 
    {
610
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
611
 
          ! gimp_drawable_is_rgb (drawable))
612
 
        success = FALSE;
613
 
 
614
 
      if (success)
615
 
        {
616
 
          gint x, y, width, height;
617
 
 
618
 
          /* The application should occur only within selection bounds */
619
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
620
 
            {
621
 
              Colorize     colors;
622
 
              PixelRegion  srcPR, destPR;
623
 
 
624
 
              colorize_init (&colors);
625
 
 
626
 
              colors.hue        = hue;
627
 
              colors.saturation = saturation;
628
 
              colors.lightness  = lightness;
629
 
 
630
 
              colorize_calculate (&colors);
631
 
 
632
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
633
 
                                 x, y, width, height, FALSE);
634
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
635
 
                                 x, y, width, height, TRUE);
636
 
 
637
 
              pixel_regions_process_parallel ((PixelProcessorFunc) colorize,
638
 
                                              &colors, 2, &srcPR, &destPR);
639
 
 
640
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize"));
641
 
              gimp_drawable_update (drawable, x, y, width, height);
642
 
            }
643
 
        }
644
 
    }
645
 
 
646
 
  return gimp_procedure_get_return_values (procedure, success);
647
 
}
648
 
 
649
 
static GValueArray *
650
 
histogram_invoker (GimpProcedure     *procedure,
651
 
                   Gimp              *gimp,
652
 
                   GimpContext       *context,
653
 
                   GimpProgress      *progress,
654
 
                   const GValueArray *args)
655
 
{
656
 
  gboolean success = TRUE;
657
 
  GValueArray *return_vals;
658
 
  GimpDrawable *drawable;
659
 
  gint32 channel;
660
 
  gint32 start_range;
661
 
  gint32 end_range;
662
 
  gdouble mean = 0.0;
663
 
  gdouble std_dev = 0.0;
664
 
  gdouble median = 0.0;
665
 
  gdouble pixels = 0.0;
666
 
  gdouble count = 0.0;
667
 
  gdouble percentile = 0.0;
668
 
 
669
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
670
 
  channel = g_value_get_enum (&args->values[1]);
671
 
  start_range = g_value_get_int (&args->values[2]);
672
 
  end_range = g_value_get_int (&args->values[3]);
673
 
 
674
 
  if (success)
675
 
    {
676
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
677
 
          gimp_drawable_is_indexed (drawable) ||
678
 
          (! gimp_drawable_has_alpha (drawable) &&
679
 
           channel == GIMP_HISTOGRAM_ALPHA) ||
680
 
          (gimp_drawable_is_gray (drawable) &&
681
 
           channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
682
 
        success = FALSE;
683
 
 
684
 
      if (success)
685
 
        {
686
 
          GimpHistogram *histogram = gimp_histogram_new ();
687
 
 
688
 
          gimp_drawable_calculate_histogram (drawable, histogram);
689
 
 
690
 
          mean       = gimp_histogram_get_mean (histogram, channel,
691
 
                                                 start_range, end_range);
692
 
          std_dev    = gimp_histogram_get_std_dev (histogram, channel,
693
 
                                                   start_range, end_range);
694
 
          median     = gimp_histogram_get_median (histogram, channel,
695
 
                                                  start_range, end_range);
696
 
          pixels     = gimp_histogram_get_count (histogram, channel, 0, 255);
697
 
          count      = gimp_histogram_get_count (histogram, channel,
698
 
                                                 start_range, end_range);
699
 
          percentile = count / pixels;
700
 
 
701
 
          gimp_histogram_free (histogram);
702
 
        }
703
 
    }
704
 
 
705
 
  return_vals = gimp_procedure_get_return_values (procedure, success);
706
 
 
707
 
  if (success)
708
 
    {
709
 
      g_value_set_double (&return_vals->values[1], mean);
710
 
      g_value_set_double (&return_vals->values[2], std_dev);
711
 
      g_value_set_double (&return_vals->values[3], median);
712
 
      g_value_set_double (&return_vals->values[4], pixels);
713
 
      g_value_set_double (&return_vals->values[5], count);
714
 
      g_value_set_double (&return_vals->values[6], percentile);
715
 
    }
716
 
 
717
 
  return return_vals;
718
 
}
719
 
 
720
 
static GValueArray *
721
 
hue_saturation_invoker (GimpProcedure     *procedure,
722
 
                        Gimp              *gimp,
723
 
                        GimpContext       *context,
724
 
                        GimpProgress      *progress,
725
 
                        const GValueArray *args)
726
 
{
727
 
  gboolean success = TRUE;
728
 
  GimpDrawable *drawable;
729
 
  gint32 hue_range;
730
 
  gdouble hue_offset;
731
 
  gdouble lightness;
732
 
  gdouble saturation;
733
 
 
734
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
735
 
  hue_range = g_value_get_enum (&args->values[1]);
736
 
  hue_offset = g_value_get_double (&args->values[2]);
737
 
  lightness = g_value_get_double (&args->values[3]);
738
 
  saturation = g_value_get_double (&args->values[4]);
739
 
 
740
 
  if (success)
741
 
    {
742
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
743
 
          gimp_drawable_is_indexed (drawable))
744
 
        success = FALSE;
745
 
 
746
 
      if (success)
747
 
        {
748
 
          gint x, y, width, height;
749
 
 
750
 
          /* The application should occur only within selection bounds */
751
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
752
 
            {
753
 
              HueSaturation  hs;
754
 
              PixelRegion    srcPR, destPR;
755
 
 
756
 
              hue_saturation_init (&hs);
757
 
 
758
 
              hs.hue[hue_range]        = hue_offset;
759
 
              hs.lightness[hue_range]  = lightness;
760
 
              hs.saturation[hue_range] = saturation;
761
 
 
762
 
              /* Calculate the transfer arrays */
763
 
              hue_saturation_calculate_transfers (&hs);
764
 
 
765
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
766
 
                                 x, y, width, height, FALSE);
767
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
768
 
                                 x, y, width, height, TRUE);
769
 
 
770
 
              pixel_regions_process_parallel ((PixelProcessorFunc) hue_saturation,
771
 
                                              &hs, 2, &srcPR, &destPR);
772
 
 
773
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation"));
774
 
              gimp_drawable_update (drawable, x, y, width, height);
775
 
            }
776
 
        }
777
 
    }
778
 
 
779
 
  return gimp_procedure_get_return_values (procedure, success);
780
 
}
781
 
 
782
 
static GValueArray *
783
 
threshold_invoker (GimpProcedure     *procedure,
784
 
                   Gimp              *gimp,
785
 
                   GimpContext       *context,
786
 
                   GimpProgress      *progress,
787
 
                   const GValueArray *args)
788
 
{
789
 
  gboolean success = TRUE;
790
 
  GimpDrawable *drawable;
791
 
  gint32 low_threshold;
792
 
  gint32 high_threshold;
793
 
 
794
 
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
795
 
  low_threshold = g_value_get_int (&args->values[1]);
796
 
  high_threshold = g_value_get_int (&args->values[2]);
797
 
 
798
 
  if (success)
799
 
    {
800
 
      if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
801
 
          gimp_drawable_is_indexed (drawable) ||
802
 
          (low_threshold > high_threshold))
803
 
        success = FALSE;
804
 
 
805
 
      if (success)
806
 
        {
807
 
          gint x, y, width, height;
808
 
 
809
 
          /* The application should occur only within selection bounds */
810
 
          if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
811
 
            {
812
 
              Threshold   tr;
813
 
              PixelRegion srcPR, destPR;
814
 
 
815
 
              tr.color          = gimp_drawable_is_rgb (drawable);
816
 
              tr.low_threshold  = low_threshold;
817
 
              tr.high_threshold = high_threshold;
818
 
 
819
 
              pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
820
 
                                 x, y, width, height, FALSE);
821
 
              pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
822
 
                                 x, y, width, height, TRUE);
823
 
 
824
 
              pixel_regions_process_parallel ((PixelProcessorFunc) threshold,
825
 
                                              &tr, 2, &srcPR, &destPR);
826
 
 
827
 
              gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold"));
828
 
              gimp_drawable_update (drawable, x, y, width, height);
829
 
            }
830
 
        }
831
 
    }
832
 
 
833
 
  return gimp_procedure_get_return_values (procedure, success);
834
 
}
835
 
 
836
 
void
837
 
register_color_procs (GimpPDB *pdb)
838
 
{
839
 
  GimpProcedure *procedure;
840
 
 
841
 
  /*
842
 
   * gimp-brightness-contrast
843
 
   */
844
 
  procedure = gimp_procedure_new (brightness_contrast_invoker);
845
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-brightness-contrast");
846
 
  gimp_procedure_set_static_strings (procedure,
847
 
                                     "gimp-brightness-contrast",
848
 
                                     "Modify brightness/contrast in the specified drawable.",
849
 
                                     "This procedures allows the brightness and contrast of the specified drawable to be modified. Both 'brightness' and 'contrast' parameters are defined between -127 and 127.",
850
 
                                     "Spencer Kimball & Peter Mattis",
851
 
                                     "Spencer Kimball & Peter Mattis",
852
 
                                     "1997",
853
 
                                     NULL);
854
 
  gimp_procedure_add_argument (procedure,
855
 
                               gimp_param_spec_drawable_id ("drawable",
856
 
                                                            "drawable",
857
 
                                                            "The drawable",
858
 
                                                            pdb->gimp, FALSE,
859
 
                                                            GIMP_PARAM_READWRITE));
860
 
  gimp_procedure_add_argument (procedure,
861
 
                               gimp_param_spec_int32 ("brightness",
862
 
                                                      "brightness",
863
 
                                                      "Brightness adjustment",
864
 
                                                      -127, 127, -127,
865
 
                                                      GIMP_PARAM_READWRITE));
866
 
  gimp_procedure_add_argument (procedure,
867
 
                               gimp_param_spec_int32 ("contrast",
868
 
                                                      "contrast",
869
 
                                                      "Contrast adjustment",
870
 
                                                      -127, 127, -127,
871
 
                                                      GIMP_PARAM_READWRITE));
872
 
  gimp_pdb_register_procedure (pdb, procedure);
873
 
  g_object_unref (procedure);
874
 
 
875
 
  /*
876
 
   * gimp-levels
877
 
   */
878
 
  procedure = gimp_procedure_new (levels_invoker);
879
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-levels");
880
 
  gimp_procedure_set_static_strings (procedure,
881
 
                                     "gimp-levels",
882
 
                                     "Modifies intensity levels in the specified drawable.",
883
 
                                     "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. It will not operate on indexed drawables.",
884
 
                                     "Spencer Kimball & Peter Mattis",
885
 
                                     "Spencer Kimball & Peter Mattis",
886
 
                                     "1995-1996",
887
 
                                     NULL);
888
 
  gimp_procedure_add_argument (procedure,
889
 
                               gimp_param_spec_drawable_id ("drawable",
890
 
                                                            "drawable",
891
 
                                                            "The drawable",
892
 
                                                            pdb->gimp, FALSE,
893
 
                                                            GIMP_PARAM_READWRITE));
894
 
  gimp_procedure_add_argument (procedure,
895
 
                               g_param_spec_enum ("channel",
896
 
                                                  "channel",
897
 
                                                  "The channel to modify",
898
 
                                                  GIMP_TYPE_HISTOGRAM_CHANNEL,
899
 
                                                  GIMP_HISTOGRAM_VALUE,
900
 
                                                  GIMP_PARAM_READWRITE));
901
 
  gimp_procedure_add_argument (procedure,
902
 
                               gimp_param_spec_int32 ("low-input",
903
 
                                                      "low input",
904
 
                                                      "Intensity of lowest input",
905
 
                                                      0, 255, 0,
906
 
                                                      GIMP_PARAM_READWRITE));
907
 
  gimp_procedure_add_argument (procedure,
908
 
                               gimp_param_spec_int32 ("high-input",
909
 
                                                      "high input",
910
 
                                                      "Intensity of highest input",
911
 
                                                      0, 255, 0,
912
 
                                                      GIMP_PARAM_READWRITE));
913
 
  gimp_procedure_add_argument (procedure,
914
 
                               g_param_spec_double ("gamma",
915
 
                                                    "gamma",
916
 
                                                    "Gamma correction factor",
917
 
                                                    0.1, 10, 0.1,
918
 
                                                    GIMP_PARAM_READWRITE));
919
 
  gimp_procedure_add_argument (procedure,
920
 
                               gimp_param_spec_int32 ("low-output",
921
 
                                                      "low output",
922
 
                                                      "Intensity of lowest output",
923
 
                                                      0, 255, 0,
924
 
                                                      GIMP_PARAM_READWRITE));
925
 
  gimp_procedure_add_argument (procedure,
926
 
                               gimp_param_spec_int32 ("high-output",
927
 
                                                      "high output",
928
 
                                                      "Intensity of highest output",
929
 
                                                      0, 255, 0,
930
 
                                                      GIMP_PARAM_READWRITE));
931
 
  gimp_pdb_register_procedure (pdb, procedure);
932
 
  g_object_unref (procedure);
933
 
 
934
 
  /*
935
 
   * gimp-levels-auto
936
 
   */
937
 
  procedure = gimp_procedure_new (levels_auto_invoker);
938
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-levels-auto");
939
 
  gimp_procedure_set_static_strings (procedure,
940
 
                                     "gimp-levels-auto",
941
 
                                     "This procedure is deprecated! Use 'gimp-levels-stretch' instead.",
942
 
                                     "This procedure is deprecated! Use 'gimp-levels-stretch' instead.",
943
 
                                     "",
944
 
                                     "",
945
 
                                     "",
946
 
                                     "gimp-levels-stretch");
947
 
  gimp_procedure_add_argument (procedure,
948
 
                               gimp_param_spec_drawable_id ("drawable",
949
 
                                                            "drawable",
950
 
                                                            "The drawable",
951
 
                                                            pdb->gimp, FALSE,
952
 
                                                            GIMP_PARAM_READWRITE));
953
 
  gimp_pdb_register_procedure (pdb, procedure);
954
 
  g_object_unref (procedure);
955
 
 
956
 
  /*
957
 
   * gimp-levels-stretch
958
 
   */
959
 
  procedure = gimp_procedure_new (levels_stretch_invoker);
960
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-levels-stretch");
961
 
  gimp_procedure_set_static_strings (procedure,
962
 
                                     "gimp-levels-stretch",
963
 
                                     "Automatically modifies intensity levels in the specified drawable.",
964
 
                                     "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. This procedure is only valid on RGB color and grayscale images. It will not operate on indexed drawables.",
965
 
                                     "Joao S.O. Bueno, Shawn Willden",
966
 
                                     "Joao S.O. Bueno, Shawn Willden",
967
 
                                     "2003",
968
 
                                     NULL);
969
 
  gimp_procedure_add_argument (procedure,
970
 
                               gimp_param_spec_drawable_id ("drawable",
971
 
                                                            "drawable",
972
 
                                                            "The drawable",
973
 
                                                            pdb->gimp, FALSE,
974
 
                                                            GIMP_PARAM_READWRITE));
975
 
  gimp_pdb_register_procedure (pdb, procedure);
976
 
  g_object_unref (procedure);
977
 
 
978
 
  /*
979
 
   * gimp-posterize
980
 
   */
981
 
  procedure = gimp_procedure_new (posterize_invoker);
982
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-posterize");
983
 
  gimp_procedure_set_static_strings (procedure,
984
 
                                     "gimp-posterize",
985
 
                                     "Posterize the specified drawable.",
986
 
                                     "This procedures reduces the number of shades allows in each intensity channel to the specified 'levels' parameter.",
987
 
                                     "Spencer Kimball & Peter Mattis",
988
 
                                     "Spencer Kimball & Peter Mattis",
989
 
                                     "1997",
990
 
                                     NULL);
991
 
  gimp_procedure_add_argument (procedure,
992
 
                               gimp_param_spec_drawable_id ("drawable",
993
 
                                                            "drawable",
994
 
                                                            "The drawable",
995
 
                                                            pdb->gimp, FALSE,
996
 
                                                            GIMP_PARAM_READWRITE));
997
 
  gimp_procedure_add_argument (procedure,
998
 
                               gimp_param_spec_int32 ("levels",
999
 
                                                      "levels",
1000
 
                                                      "Levels of posterization",
1001
 
                                                      2, 255, 2,
1002
 
                                                      GIMP_PARAM_READWRITE));
1003
 
  gimp_pdb_register_procedure (pdb, procedure);
1004
 
  g_object_unref (procedure);
1005
 
 
1006
 
  /*
1007
 
   * gimp-desaturate
1008
 
   */
1009
 
  procedure = gimp_procedure_new (desaturate_invoker);
1010
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-desaturate");
1011
 
  gimp_procedure_set_static_strings (procedure,
1012
 
                                     "gimp-desaturate",
1013
 
                                     "Desaturate the contents of the specified drawable.",
1014
 
                                     "This procedure desaturates the contents of the specified drawable. This procedure only works on drawables of type RGB color.",
1015
 
                                     "Spencer Kimball & Peter Mattis",
1016
 
                                     "Spencer Kimball & Peter Mattis",
1017
 
                                     "1995-1996",
1018
 
                                     NULL);
1019
 
  gimp_procedure_add_argument (procedure,
1020
 
                               gimp_param_spec_drawable_id ("drawable",
1021
 
                                                            "drawable",
1022
 
                                                            "The drawable",
1023
 
                                                            pdb->gimp, FALSE,
1024
 
                                                            GIMP_PARAM_READWRITE));
1025
 
  gimp_pdb_register_procedure (pdb, procedure);
1026
 
  g_object_unref (procedure);
1027
 
 
1028
 
  /*
1029
 
   * gimp-desaturate-full
1030
 
   */
1031
 
  procedure = gimp_procedure_new (desaturate_full_invoker);
1032
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-desaturate-full");
1033
 
  gimp_procedure_set_static_strings (procedure,
1034
 
                                     "gimp-desaturate-full",
1035
 
                                     "Desaturate the contents of the specified drawable, with the specified formula.",
1036
 
                                     "This procedure desaturates the contents of the specified drawable, with the specified formula. This procedure only works on drawables of type RGB color.",
1037
 
                                     "Karine Delvare",
1038
 
                                     "Karine Delvare",
1039
 
                                     "2005",
1040
 
                                     NULL);
1041
 
  gimp_procedure_add_argument (procedure,
1042
 
                               gimp_param_spec_drawable_id ("drawable",
1043
 
                                                            "drawable",
1044
 
                                                            "The drawable",
1045
 
                                                            pdb->gimp, FALSE,
1046
 
                                                            GIMP_PARAM_READWRITE));
1047
 
  gimp_procedure_add_argument (procedure,
1048
 
                               g_param_spec_enum ("desaturate-mode",
1049
 
                                                  "desaturate mode",
1050
 
                                                  "The formula to use to desaturate",
1051
 
                                                  GIMP_TYPE_DESATURATE_MODE,
1052
 
                                                  GIMP_DESATURATE_LIGHTNESS,
1053
 
                                                  GIMP_PARAM_READWRITE));
1054
 
  gimp_pdb_register_procedure (pdb, procedure);
1055
 
  g_object_unref (procedure);
1056
 
 
1057
 
  /*
1058
 
   * gimp-equalize
1059
 
   */
1060
 
  procedure = gimp_procedure_new (equalize_invoker);
1061
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-equalize");
1062
 
  gimp_procedure_set_static_strings (procedure,
1063
 
                                     "gimp-equalize",
1064
 
                                     "Equalize the contents of the specified drawable.",
1065
 
                                     "This procedure equalizes the contents of the specified drawable. Each intensity channel is equalizeed independently. The equalized intensity is given as inten' = (255 - inten). Indexed color drawables are not valid for this operation. 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.",
1066
 
                                     "Spencer Kimball & Peter Mattis",
1067
 
                                     "Spencer Kimball & Peter Mattis",
1068
 
                                     "1995-1996",
1069
 
                                     NULL);
1070
 
  gimp_procedure_add_argument (procedure,
1071
 
                               gimp_param_spec_drawable_id ("drawable",
1072
 
                                                            "drawable",
1073
 
                                                            "The drawable",
1074
 
                                                            pdb->gimp, FALSE,
1075
 
                                                            GIMP_PARAM_READWRITE));
1076
 
  gimp_procedure_add_argument (procedure,
1077
 
                               g_param_spec_boolean ("mask-only",
1078
 
                                                     "mask only",
1079
 
                                                     "Equalization option",
1080
 
                                                     FALSE,
1081
 
                                                     GIMP_PARAM_READWRITE));
1082
 
  gimp_pdb_register_procedure (pdb, procedure);
1083
 
  g_object_unref (procedure);
1084
 
 
1085
 
  /*
1086
 
   * gimp-invert
1087
 
   */
1088
 
  procedure = gimp_procedure_new (invert_invoker);
1089
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-invert");
1090
 
  gimp_procedure_set_static_strings (procedure,
1091
 
                                     "gimp-invert",
1092
 
                                     "Invert the contents of the specified drawable.",
1093
 
                                     "This procedure inverts the contents of the specified drawable. Each intensity channel is inverted independently. The inverted intensity is given as inten' = (255 - inten). Indexed color drawables are not valid for this operation.",
1094
 
                                     "Spencer Kimball & Peter Mattis",
1095
 
                                     "Spencer Kimball & Peter Mattis",
1096
 
                                     "1995-1996",
1097
 
                                     NULL);
1098
 
  gimp_procedure_add_argument (procedure,
1099
 
                               gimp_param_spec_drawable_id ("drawable",
1100
 
                                                            "drawable",
1101
 
                                                            "The drawable",
1102
 
                                                            pdb->gimp, FALSE,
1103
 
                                                            GIMP_PARAM_READWRITE));
1104
 
  gimp_pdb_register_procedure (pdb, procedure);
1105
 
  g_object_unref (procedure);
1106
 
 
1107
 
  /*
1108
 
   * gimp-curves-spline
1109
 
   */
1110
 
  procedure = gimp_procedure_new (curves_spline_invoker);
1111
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-curves-spline");
1112
 
  gimp_procedure_set_static_strings (procedure,
1113
 
                                     "gimp-curves-spline",
1114
 
                                     "Modifies the intensity curve(s) for specified drawable.",
1115
 
                                     "Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'control_pts' parameter is an array of integers 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.",
1116
 
                                     "Spencer Kimball & Peter Mattis",
1117
 
                                     "Spencer Kimball & Peter Mattis",
1118
 
                                     "1995-1996",
1119
 
                                     NULL);
1120
 
  gimp_procedure_add_argument (procedure,
1121
 
                               gimp_param_spec_drawable_id ("drawable",
1122
 
                                                            "drawable",
1123
 
                                                            "The drawable",
1124
 
                                                            pdb->gimp, FALSE,
1125
 
                                                            GIMP_PARAM_READWRITE));
1126
 
  gimp_procedure_add_argument (procedure,
1127
 
                               g_param_spec_enum ("channel",
1128
 
                                                  "channel",
1129
 
                                                  "The channel to modify",
1130
 
                                                  GIMP_TYPE_HISTOGRAM_CHANNEL,
1131
 
                                                  GIMP_HISTOGRAM_VALUE,
1132
 
                                                  GIMP_PARAM_READWRITE));
1133
 
  gimp_procedure_add_argument (procedure,
1134
 
                               gimp_param_spec_int32 ("num-points",
1135
 
                                                      "num points",
1136
 
                                                      "The number of values in the control point array",
1137
 
                                                      4, 34, 4,
1138
 
                                                      GIMP_PARAM_READWRITE));
1139
 
  gimp_procedure_add_argument (procedure,
1140
 
                               gimp_param_spec_int8_array ("control-pts",
1141
 
                                                           "control pts",
1142
 
                                                           "The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }",
1143
 
                                                           GIMP_PARAM_READWRITE));
1144
 
  gimp_pdb_register_procedure (pdb, procedure);
1145
 
  g_object_unref (procedure);
1146
 
 
1147
 
  /*
1148
 
   * gimp-curves-explicit
1149
 
   */
1150
 
  procedure = gimp_procedure_new (curves_explicit_invoker);
1151
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-curves-explicit");
1152
 
  gimp_procedure_set_static_strings (procedure,
1153
 
                                     "gimp-curves-explicit",
1154
 
                                     "Modifies the intensity curve(s) for specified drawable.",
1155
 
                                     "Modifies the intensity mapping for one channel in the specified drawable. The drawable must be either grayscale or RGB, and the channel can be either an intensity component, or the value. The 'curve' parameter is an array of bytes 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.",
1156
 
                                     "Spencer Kimball & Peter Mattis",
1157
 
                                     "Spencer Kimball & Peter Mattis",
1158
 
                                     "1995-1996",
1159
 
                                     NULL);
1160
 
  gimp_procedure_add_argument (procedure,
1161
 
                               gimp_param_spec_drawable_id ("drawable",
1162
 
                                                            "drawable",
1163
 
                                                            "The drawable",
1164
 
                                                            pdb->gimp, FALSE,
1165
 
                                                            GIMP_PARAM_READWRITE));
1166
 
  gimp_procedure_add_argument (procedure,
1167
 
                               g_param_spec_enum ("channel",
1168
 
                                                  "channel",
1169
 
                                                  "The channel to modify",
1170
 
                                                  GIMP_TYPE_HISTOGRAM_CHANNEL,
1171
 
                                                  GIMP_HISTOGRAM_VALUE,
1172
 
                                                  GIMP_PARAM_READWRITE));
1173
 
  gimp_procedure_add_argument (procedure,
1174
 
                               gimp_param_spec_int32 ("num-bytes",
1175
 
                                                      "num bytes",
1176
 
                                                      "The number of bytes in the new curve (always 256)",
1177
 
                                                      0, G_MAXINT32, 0,
1178
 
                                                      GIMP_PARAM_READWRITE));
1179
 
  gimp_procedure_add_argument (procedure,
1180
 
                               gimp_param_spec_int8_array ("curve",
1181
 
                                                           "curve",
1182
 
                                                           "The explicit curve",
1183
 
                                                           GIMP_PARAM_READWRITE));
1184
 
  gimp_pdb_register_procedure (pdb, procedure);
1185
 
  g_object_unref (procedure);
1186
 
 
1187
 
  /*
1188
 
   * gimp-color-balance
1189
 
   */
1190
 
  procedure = gimp_procedure_new (color_balance_invoker);
1191
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-color-balance");
1192
 
  gimp_procedure_set_static_strings (procedure,
1193
 
                                     "gimp-color-balance",
1194
 
                                     "Modify the color balance of the specified drawable.",
1195
 
                                     "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.",
1196
 
                                     "Spencer Kimball & Peter Mattis",
1197
 
                                     "Spencer Kimball & Peter Mattis",
1198
 
                                     "1997",
1199
 
                                     NULL);
1200
 
  gimp_procedure_add_argument (procedure,
1201
 
                               gimp_param_spec_drawable_id ("drawable",
1202
 
                                                            "drawable",
1203
 
                                                            "The drawable",
1204
 
                                                            pdb->gimp, FALSE,
1205
 
                                                            GIMP_PARAM_READWRITE));
1206
 
  gimp_procedure_add_argument (procedure,
1207
 
                               g_param_spec_enum ("transfer-mode",
1208
 
                                                  "transfer mode",
1209
 
                                                  "Transfer mode",
1210
 
                                                  GIMP_TYPE_TRANSFER_MODE,
1211
 
                                                  GIMP_SHADOWS,
1212
 
                                                  GIMP_PARAM_READWRITE));
1213
 
  gimp_procedure_add_argument (procedure,
1214
 
                               g_param_spec_boolean ("preserve-lum",
1215
 
                                                     "preserve lum",
1216
 
                                                     "Preserve luminosity values at each pixel",
1217
 
                                                     FALSE,
1218
 
                                                     GIMP_PARAM_READWRITE));
1219
 
  gimp_procedure_add_argument (procedure,
1220
 
                               g_param_spec_double ("cyan-red",
1221
 
                                                    "cyan red",
1222
 
                                                    "Cyan-Red color balance",
1223
 
                                                    -100, 100, -100,
1224
 
                                                    GIMP_PARAM_READWRITE));
1225
 
  gimp_procedure_add_argument (procedure,
1226
 
                               g_param_spec_double ("magenta-green",
1227
 
                                                    "magenta green",
1228
 
                                                    "Magenta-Green color balance",
1229
 
                                                    -100, 100, -100,
1230
 
                                                    GIMP_PARAM_READWRITE));
1231
 
  gimp_procedure_add_argument (procedure,
1232
 
                               g_param_spec_double ("yellow-blue",
1233
 
                                                    "yellow blue",
1234
 
                                                    "Yellow-Blue color balance",
1235
 
                                                    -100, 100, -100,
1236
 
                                                    GIMP_PARAM_READWRITE));
1237
 
  gimp_pdb_register_procedure (pdb, procedure);
1238
 
  g_object_unref (procedure);
1239
 
 
1240
 
  /*
1241
 
   * gimp-colorize
1242
 
   */
1243
 
  procedure = gimp_procedure_new (colorize_invoker);
1244
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-colorize");
1245
 
  gimp_procedure_set_static_strings (procedure,
1246
 
                                     "gimp-colorize",
1247
 
                                     "Render the drawable as a grayscale image seen through a colored glass.",
1248
 
                                     "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 or indexed drawables.",
1249
 
                                     "Sven Neumann <sven@gimp.org>",
1250
 
                                     "Sven Neumann",
1251
 
                                     "2004",
1252
 
                                     NULL);
1253
 
  gimp_procedure_add_argument (procedure,
1254
 
                               gimp_param_spec_drawable_id ("drawable",
1255
 
                                                            "drawable",
1256
 
                                                            "The drawable",
1257
 
                                                            pdb->gimp, FALSE,
1258
 
                                                            GIMP_PARAM_READWRITE));
1259
 
  gimp_procedure_add_argument (procedure,
1260
 
                               g_param_spec_double ("hue",
1261
 
                                                    "hue",
1262
 
                                                    "Hue in degrees",
1263
 
                                                    0, 360, 0,
1264
 
                                                    GIMP_PARAM_READWRITE));
1265
 
  gimp_procedure_add_argument (procedure,
1266
 
                               g_param_spec_double ("saturation",
1267
 
                                                    "saturation",
1268
 
                                                    "Saturation in percent",
1269
 
                                                    0, 100, 0,
1270
 
                                                    GIMP_PARAM_READWRITE));
1271
 
  gimp_procedure_add_argument (procedure,
1272
 
                               g_param_spec_double ("lightness",
1273
 
                                                    "lightness",
1274
 
                                                    "Lightness in percent",
1275
 
                                                    -100, 100, -100,
1276
 
                                                    GIMP_PARAM_READWRITE));
1277
 
  gimp_pdb_register_procedure (pdb, procedure);
1278
 
  g_object_unref (procedure);
1279
 
 
1280
 
  /*
1281
 
   * gimp-histogram
1282
 
   */
1283
 
  procedure = gimp_procedure_new (histogram_invoker);
1284
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-histogram");
1285
 
  gimp_procedure_set_static_strings (procedure,
1286
 
                                     "gimp-histogram",
1287
 
                                     "Returns information on the intensity histogram for the specified drawable.",
1288
 
                                     "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. The drawable may not be indexed. Second, a range of intensities are specified. The 'gimp-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 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.",
1289
 
                                     "Spencer Kimball & Peter Mattis",
1290
 
                                     "Spencer Kimball & Peter Mattis",
1291
 
                                     "1995-1996",
1292
 
                                     NULL);
1293
 
  gimp_procedure_add_argument (procedure,
1294
 
                               gimp_param_spec_drawable_id ("drawable",
1295
 
                                                            "drawable",
1296
 
                                                            "The drawable",
1297
 
                                                            pdb->gimp, FALSE,
1298
 
                                                            GIMP_PARAM_READWRITE));
1299
 
  gimp_procedure_add_argument (procedure,
1300
 
                               g_param_spec_enum ("channel",
1301
 
                                                  "channel",
1302
 
                                                  "The channel to modify",
1303
 
                                                  GIMP_TYPE_HISTOGRAM_CHANNEL,
1304
 
                                                  GIMP_HISTOGRAM_VALUE,
1305
 
                                                  GIMP_PARAM_READWRITE));
1306
 
  gimp_procedure_add_argument (procedure,
1307
 
                               gimp_param_spec_int32 ("start-range",
1308
 
                                                      "start range",
1309
 
                                                      "Start of the intensity measurement range",
1310
 
                                                      0, 256, 0,
1311
 
                                                      GIMP_PARAM_READWRITE));
1312
 
  gimp_procedure_add_argument (procedure,
1313
 
                               gimp_param_spec_int32 ("end-range",
1314
 
                                                      "end range",
1315
 
                                                      "End of the intensity measurement range",
1316
 
                                                      0, 256, 0,
1317
 
                                                      GIMP_PARAM_READWRITE));
1318
 
  gimp_procedure_add_return_value (procedure,
1319
 
                                   g_param_spec_double ("mean",
1320
 
                                                        "mean",
1321
 
                                                        "Mean intensity value",
1322
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1323
 
                                                        GIMP_PARAM_READWRITE));
1324
 
  gimp_procedure_add_return_value (procedure,
1325
 
                                   g_param_spec_double ("std-dev",
1326
 
                                                        "std dev",
1327
 
                                                        "Standard deviation of intensity values",
1328
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1329
 
                                                        GIMP_PARAM_READWRITE));
1330
 
  gimp_procedure_add_return_value (procedure,
1331
 
                                   g_param_spec_double ("median",
1332
 
                                                        "median",
1333
 
                                                        "Median intensity value",
1334
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1335
 
                                                        GIMP_PARAM_READWRITE));
1336
 
  gimp_procedure_add_return_value (procedure,
1337
 
                                   g_param_spec_double ("pixels",
1338
 
                                                        "pixels",
1339
 
                                                        "Alpha-weighted pixel count for entire image",
1340
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1341
 
                                                        GIMP_PARAM_READWRITE));
1342
 
  gimp_procedure_add_return_value (procedure,
1343
 
                                   g_param_spec_double ("count",
1344
 
                                                        "count",
1345
 
                                                        "Alpha-weighted pixel count for range",
1346
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1347
 
                                                        GIMP_PARAM_READWRITE));
1348
 
  gimp_procedure_add_return_value (procedure,
1349
 
                                   g_param_spec_double ("percentile",
1350
 
                                                        "percentile",
1351
 
                                                        "Percentile that range falls under",
1352
 
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1353
 
                                                        GIMP_PARAM_READWRITE));
1354
 
  gimp_pdb_register_procedure (pdb, procedure);
1355
 
  g_object_unref (procedure);
1356
 
 
1357
 
  /*
1358
 
   * gimp-hue-saturation
1359
 
   */
1360
 
  procedure = gimp_procedure_new (hue_saturation_invoker);
1361
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-hue-saturation");
1362
 
  gimp_procedure_set_static_strings (procedure,
1363
 
                                     "gimp-hue-saturation",
1364
 
                                     "Modify hue, lightness, and saturation in the specified drawable.",
1365
 
                                     "This procedures 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.",
1366
 
                                     "Spencer Kimball & Peter Mattis",
1367
 
                                     "Spencer Kimball & Peter Mattis",
1368
 
                                     "1997",
1369
 
                                     NULL);
1370
 
  gimp_procedure_add_argument (procedure,
1371
 
                               gimp_param_spec_drawable_id ("drawable",
1372
 
                                                            "drawable",
1373
 
                                                            "The drawable",
1374
 
                                                            pdb->gimp, FALSE,
1375
 
                                                            GIMP_PARAM_READWRITE));
1376
 
  gimp_procedure_add_argument (procedure,
1377
 
                               g_param_spec_enum ("hue-range",
1378
 
                                                  "hue range",
1379
 
                                                  "Range of affected hues",
1380
 
                                                  GIMP_TYPE_HUE_RANGE,
1381
 
                                                  GIMP_ALL_HUES,
1382
 
                                                  GIMP_PARAM_READWRITE));
1383
 
  gimp_procedure_add_argument (procedure,
1384
 
                               g_param_spec_double ("hue-offset",
1385
 
                                                    "hue offset",
1386
 
                                                    "Hue offset in degrees",
1387
 
                                                    -180, 180, -180,
1388
 
                                                    GIMP_PARAM_READWRITE));
1389
 
  gimp_procedure_add_argument (procedure,
1390
 
                               g_param_spec_double ("lightness",
1391
 
                                                    "lightness",
1392
 
                                                    "Lightness modification",
1393
 
                                                    -100, 100, -100,
1394
 
                                                    GIMP_PARAM_READWRITE));
1395
 
  gimp_procedure_add_argument (procedure,
1396
 
                               g_param_spec_double ("saturation",
1397
 
                                                    "saturation",
1398
 
                                                    "Saturation modification",
1399
 
                                                    -100, 100, -100,
1400
 
                                                    GIMP_PARAM_READWRITE));
1401
 
  gimp_pdb_register_procedure (pdb, procedure);
1402
 
  g_object_unref (procedure);
1403
 
 
1404
 
  /*
1405
 
   * gimp-threshold
1406
 
   */
1407
 
  procedure = gimp_procedure_new (threshold_invoker);
1408
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-threshold");
1409
 
  gimp_procedure_set_static_strings (procedure,
1410
 
                                     "gimp-threshold",
1411
 
                                     "Threshold the specified drawable.",
1412
 
                                     "This procedures generates a threshold map of the specified drawable. All pixels between the values of 'low_threshold' and 'high_threshold' are replaced with white, and all other pixels with black.",
1413
 
                                     "Spencer Kimball & Peter Mattis",
1414
 
                                     "Spencer Kimball & Peter Mattis",
1415
 
                                     "1997",
1416
 
                                     NULL);
1417
 
  gimp_procedure_add_argument (procedure,
1418
 
                               gimp_param_spec_drawable_id ("drawable",
1419
 
                                                            "drawable",
1420
 
                                                            "The drawable",
1421
 
                                                            pdb->gimp, FALSE,
1422
 
                                                            GIMP_PARAM_READWRITE));
1423
 
  gimp_procedure_add_argument (procedure,
1424
 
                               gimp_param_spec_int32 ("low-threshold",
1425
 
                                                      "low threshold",
1426
 
                                                      "The low threshold value",
1427
 
                                                      0, 255, 0,
1428
 
                                                      GIMP_PARAM_READWRITE));
1429
 
  gimp_procedure_add_argument (procedure,
1430
 
                               gimp_param_spec_int32 ("high-threshold",
1431
 
                                                      "high threshold",
1432
 
                                                      "The high threshold value",
1433
 
                                                      0, 255, 0,
1434
 
                                                      GIMP_PARAM_READWRITE));
1435
 
  gimp_pdb_register_procedure (pdb, procedure);
1436
 
  g_object_unref (procedure);
1437
 
}