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

« back to all changes in this revision

Viewing changes to app/core/gimpchannel-select.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
21
21
#include <glib-object.h>
22
22
 
23
23
#include "libgimpbase/gimpbase.h"
24
 
#include "libgimpcolor/gimpcolor.h"
 
24
#include "libgimpmath/gimpmath.h"
25
25
 
26
26
#include "core-types.h"
27
27
 
48
48
                               GimpChannelOps  op,
49
49
                               gboolean        feather,
50
50
                               gdouble         feather_radius_x,
51
 
                               gdouble         feather_radius_y)
 
51
                               gdouble         feather_radius_y,
 
52
                               gboolean        push_undo)
52
53
{
53
54
  g_return_if_fail (GIMP_IS_CHANNEL (channel));
54
55
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
55
56
 
56
 
  gimp_channel_push_undo (channel, _("Rect Select"));
 
57
  if (push_undo)
 
58
    gimp_channel_push_undo (channel, Q_("command|Rectangle Select"));
57
59
 
58
60
  /*  if applicable, replace the current selection  */
59
61
  if (op == GIMP_CHANNEL_OP_REPLACE)
64
66
   */
65
67
  if (feather || op == GIMP_CHANNEL_OP_INTERSECT)
66
68
    {
67
 
      GimpItem    *item;
 
69
      GimpItem    *item = GIMP_ITEM (channel);
68
70
      GimpChannel *add_on;
69
71
 
70
 
      item = GIMP_ITEM (channel);
71
 
 
72
72
      add_on = gimp_channel_new_mask (gimp_item_get_image (item),
73
73
                                      gimp_item_width (item),
74
74
                                      gimp_item_height (item));
99
99
                             gboolean        antialias,
100
100
                             gboolean        feather,
101
101
                             gdouble         feather_radius_x,
102
 
                             gdouble         feather_radius_y)
 
102
                             gdouble         feather_radius_y,
 
103
                             gboolean        push_undo)
103
104
{
104
105
  g_return_if_fail (GIMP_IS_CHANNEL (channel));
105
106
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
106
107
 
107
 
  gimp_channel_push_undo (channel, _("Ellipse Select"));
 
108
  if (push_undo)
 
109
    gimp_channel_push_undo (channel, Q_("command|Ellipse Select"));
108
110
 
109
111
  /*  if applicable, replace the current selection  */
110
112
  if (op == GIMP_CHANNEL_OP_REPLACE)
115
117
   */
116
118
  if (feather || op == GIMP_CHANNEL_OP_INTERSECT)
117
119
    {
118
 
      GimpItem    *item;
 
120
      GimpItem    *item = GIMP_ITEM (channel);
119
121
      GimpChannel *add_on;
120
122
 
121
 
      item = GIMP_ITEM (channel);
122
 
 
123
123
      add_on = gimp_channel_new_mask (gimp_item_get_image (item),
124
124
                                      gimp_item_width (item),
125
125
                                      gimp_item_height (item));
141
141
    }
142
142
}
143
143
 
 
144
void
 
145
gimp_channel_select_round_rect (GimpChannel         *channel,
 
146
                                gint                 x,
 
147
                                gint                 y,
 
148
                                gint                 w,
 
149
                                gint                 h,
 
150
                                gdouble              corner_radius_x,
 
151
                                gdouble              corner_radius_y,
 
152
                                GimpChannelOps       op,
 
153
                                gboolean             antialias,
 
154
                                gboolean             feather,
 
155
                                gdouble              feather_radius_x,
 
156
                                gdouble              feather_radius_y,
 
157
                                gboolean             push_undo)
 
158
{
 
159
  g_return_if_fail (GIMP_IS_CHANNEL (channel));
 
160
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
 
161
 
 
162
  if (push_undo)
 
163
    gimp_channel_push_undo (channel, Q_("command|Rounded Rectangle Select"));
 
164
 
 
165
  /*  if applicable, replace the current selection  */
 
166
  if (op == GIMP_CHANNEL_OP_REPLACE)
 
167
    gimp_channel_clear (channel, NULL, FALSE);
 
168
 
 
169
  /*  if feathering for rect, make a new mask with the
 
170
   *  rectangle and feather that with the old mask
 
171
   */
 
172
  if (feather || op == GIMP_CHANNEL_OP_INTERSECT)
 
173
    {
 
174
      GimpItem    *item = GIMP_ITEM (channel);
 
175
      GimpChannel *add_on;
 
176
 
 
177
      add_on = gimp_channel_new_mask (gimp_item_get_image (item),
 
178
                                      gimp_item_width (item),
 
179
                                      gimp_item_height (item));
 
180
      gimp_channel_combine_ellipse_rect (add_on, GIMP_CHANNEL_OP_ADD,
 
181
                                         x, y, w, h,
 
182
                                         corner_radius_x, corner_radius_y,
 
183
                                         antialias);
 
184
 
 
185
      if (feather)
 
186
        gimp_channel_feather (add_on,
 
187
                              feather_radius_x,
 
188
                              feather_radius_y,
 
189
                              FALSE /* no undo */);
 
190
 
 
191
      gimp_channel_combine_mask (channel, add_on, op, 0, 0);
 
192
      g_object_unref (add_on);
 
193
    }
 
194
  else
 
195
    {
 
196
      gimp_channel_combine_ellipse_rect (channel, op, x, y, w, h,
 
197
                                         corner_radius_x, corner_radius_y,
 
198
                                         antialias);
 
199
    }
 
200
}
144
201
 
145
202
/*  select by GimpScanConvert functions  */
146
203
 
154
211
                                  gboolean         antialias,
155
212
                                  gboolean         feather,
156
213
                                  gdouble          feather_radius_x,
157
 
                                  gdouble          feather_radius_y)
 
214
                                  gdouble          feather_radius_y,
 
215
                                  gboolean         push_undo)
158
216
{
159
217
  GimpItem    *item;
160
218
  GimpChannel *add_on;
164
222
  g_return_if_fail (undo_desc != NULL);
165
223
  g_return_if_fail (scan_convert != NULL);
166
224
 
167
 
  gimp_channel_push_undo (channel, undo_desc);
 
225
  if (push_undo)
 
226
    gimp_channel_push_undo (channel, undo_desc);
168
227
 
169
228
  /*  if applicable, replace the current selection  */
170
229
  if (op == GIMP_CHANNEL_OP_REPLACE)
176
235
                                  gimp_item_width (item),
177
236
                                  gimp_item_height (item));
178
237
  gimp_scan_convert_render (scan_convert,
179
 
                            gimp_drawable_data (GIMP_DRAWABLE (add_on)),
 
238
                            gimp_drawable_get_tiles (GIMP_DRAWABLE (add_on)),
180
239
                            offset_x, offset_y, antialias);
181
240
 
182
241
  if (feather)
198
257
                             gboolean        antialias,
199
258
                             gboolean        feather,
200
259
                             gdouble         feather_radius_x,
201
 
                             gdouble         feather_radius_y)
 
260
                             gdouble         feather_radius_y,
 
261
                             gboolean        push_undo)
202
262
{
203
263
  GimpScanConvert *scan_convert;
204
264
 
212
272
 
213
273
  gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
214
274
                                    op, antialias, feather,
215
 
                                    feather_radius_x, feather_radius_y);
 
275
                                    feather_radius_x, feather_radius_y,
 
276
                                    push_undo);
216
277
 
217
278
  gimp_scan_convert_free (scan_convert);
218
279
}
225
286
                             gboolean        antialias,
226
287
                             gboolean        feather,
227
288
                             gdouble         feather_radius_x,
228
 
                             gdouble         feather_radius_y)
 
289
                             gdouble         feather_radius_y,
 
290
                             gboolean        push_undo)
229
291
{
230
292
  GimpScanConvert *scan_convert;
231
293
  GList           *stroke;
273
335
  if (coords_added)
274
336
    gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
275
337
                                      op, antialias, feather,
276
 
                                      feather_radius_x, feather_radius_y);
 
338
                                      feather_radius_x, feather_radius_y,
 
339
                                      push_undo);
277
340
 
278
341
  gimp_scan_convert_free (scan_convert);
279
342
}
350
413
 
351
414
  if (gimp_drawable_has_alpha (drawable))
352
415
    {
353
 
      GimpRGB color;
354
 
 
355
 
      gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
356
 
 
357
416
      add_on = gimp_channel_new_from_alpha (gimp_item_get_image (item),
358
 
                                            drawable, NULL, &color);
 
417
                                            drawable, NULL, NULL);
359
418
    }
360
419
  else
361
420
    {
388
447
{
389
448
  GimpItem    *item;
390
449
  GimpChannel *add_on;
391
 
  GimpRGB      color;
392
450
  const gchar *desc;
393
451
  gchar       *undo_desc;
394
452
 
395
453
  g_return_if_fail (GIMP_IS_CHANNEL (channel));
396
454
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
397
455
 
398
 
  gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
399
 
 
400
456
  item = GIMP_ITEM (channel);
401
457
 
402
458
  add_on = gimp_channel_new_from_component (gimp_item_get_image (item),
403
 
                                            component, NULL, &color);
 
459
                                            component, NULL, NULL);
404
460
 
405
461
  if (feather)
406
462
    gimp_channel_feather (add_on,
422
478
}
423
479
 
424
480
void
425
 
gimp_channel_select_fuzzy (GimpChannel    *channel,
426
 
                           GimpDrawable   *drawable,
427
 
                           gboolean        sample_merged,
428
 
                           gint            x,
429
 
                           gint            y,
430
 
                           gint            threshold,
431
 
                           gboolean        select_transparent,
432
 
                           GimpChannelOps  op,
433
 
                           gboolean        antialias,
434
 
                           gboolean        feather,
435
 
                           gdouble         feather_radius_x,
436
 
                           gdouble         feather_radius_y)
 
481
gimp_channel_select_fuzzy (GimpChannel         *channel,
 
482
                           GimpDrawable        *drawable,
 
483
                           gboolean             sample_merged,
 
484
                           gint                 x,
 
485
                           gint                 y,
 
486
                           gint                 threshold,
 
487
                           gboolean             select_transparent,
 
488
                           GimpSelectCriterion  select_criterion,
 
489
                           GimpChannelOps       op,
 
490
                           gboolean             antialias,
 
491
                           gboolean             feather,
 
492
                           gdouble              feather_radius_x,
 
493
                           gdouble              feather_radius_y)
437
494
{
438
495
  GimpItem    *item;
439
496
  GimpChannel *add_on;
452
509
                                                 antialias,
453
510
                                                 threshold,
454
511
                                                 select_transparent,
 
512
                                                 select_criterion,
455
513
                                                 x, y);
456
514
 
457
515
  if (! sample_merged)
458
516
    gimp_item_offsets (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
459
517
 
460
 
  gimp_channel_select_channel (channel, _("Fuzzy Select"),
 
518
  gimp_channel_select_channel (channel, Q_("command|Fuzzy Select"),
461
519
                               add_on, add_on_x, add_on_y,
462
520
                               op,
463
521
                               feather,
467
525
}
468
526
 
469
527
void
470
 
gimp_channel_select_by_color (GimpChannel    *channel,
471
 
                              GimpDrawable   *drawable,
472
 
                              gboolean        sample_merged,
473
 
                              const GimpRGB  *color,
474
 
                              gint            threshold,
475
 
                              gboolean        select_transparent,
476
 
                              GimpChannelOps  op,
477
 
                              gboolean        antialias,
478
 
                              gboolean        feather,
479
 
                              gdouble         feather_radius_x,
480
 
                              gdouble         feather_radius_y)
 
528
gimp_channel_select_by_color (GimpChannel         *channel,
 
529
                              GimpDrawable        *drawable,
 
530
                              gboolean             sample_merged,
 
531
                              const GimpRGB       *color,
 
532
                              gint                 threshold,
 
533
                              gboolean             select_transparent,
 
534
                              GimpSelectCriterion  select_criterion,
 
535
                              GimpChannelOps       op,
 
536
                              gboolean             antialias,
 
537
                              gboolean             feather,
 
538
                              gdouble              feather_radius_x,
 
539
                              gdouble              feather_radius_y)
481
540
{
482
541
  GimpItem    *item;
483
542
  GimpChannel *add_on;
497
556
                                                  antialias,
498
557
                                                  threshold,
499
558
                                                  select_transparent,
 
559
                                                  select_criterion,
500
560
                                                  color);
501
561
 
502
562
  if (! sample_merged)
503
563
    gimp_item_offsets (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
504
564
 
505
 
  gimp_channel_select_channel (channel, _("Select by Color"),
 
565
  gimp_channel_select_channel (channel, Q_("command|Select by Color"),
506
566
                               add_on, add_on_x, add_on_y,
507
567
                               op,
508
568
                               feather,