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

« back to all changes in this revision

Viewing changes to plug-ins/common/noisify.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:
17
17
 * You should have received a copy of the GNU General Public License
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
 
 *
21
 
 * $Id: noisify.c,v 1.65 2004/12/23 23:58:35 weskaggs Exp $
22
20
 */
23
21
 
24
22
/*
34
32
 
35
33
#include "config.h"
36
34
 
37
 
#include <stdlib.h>
38
 
#include <stdio.h>
39
35
#include <string.h>
40
36
 
41
 
#include <gtk/gtk.h>
42
 
 
43
37
#include <libgimp/gimp.h>
44
38
#include <libgimp/gimpui.h>
45
39
 
46
40
#include "libgimp/stdplugins-intl.h"
47
41
 
48
42
 
 
43
#define RGB_NOISE_PROC   "plug-in-rgb-noise"
 
44
#define NOISIFY_PROC     "plug-in-noisify"
 
45
#define PLUG_IN_BINARY   "noisify"
49
46
#define SCALE_WIDTH      125
50
47
#define TILE_CACHE_SIZE  16
51
48
 
90
87
                                                  gpointer       data);
91
88
 
92
89
 
93
 
GimpPlugInInfo PLUG_IN_INFO =
 
90
const GimpPlugInInfo PLUG_IN_INFO =
94
91
{
95
92
  NULL,  /* init_proc */
96
93
  NULL,  /* quit_proc */
118
115
static void
119
116
query (void)
120
117
{
121
 
  static GimpParamDef scatter_args[] =
 
118
  static const GimpParamDef scatter_args[] =
122
119
  {
123
 
    { GIMP_PDB_INT32,    "run_mode",    "Interactive, non-interactive" },
 
120
    { GIMP_PDB_INT32,    "run-mode",    "Interactive, non-interactive" },
124
121
    { GIMP_PDB_IMAGE,    "image",       "Input image (unused)" },
125
122
    { GIMP_PDB_DRAWABLE, "drawable",    "Input drawable" },
126
123
    { GIMP_PDB_INT32,    "independent", "Noise in channels independent" },
127
124
    { GIMP_PDB_INT32,    "correlated",  "Noise correlated (i.e. multiplicative not additive)" },
128
 
    { GIMP_PDB_FLOAT,    "noise_1",     "Noise in the first channel (red, gray)" },
129
 
    { GIMP_PDB_FLOAT,    "noise_2",     "Noise in the second channel (green, gray_alpha)" },
130
 
    { GIMP_PDB_FLOAT,    "noise_3",     "Noise in the third channel (blue)" },
131
 
    { GIMP_PDB_FLOAT,    "noise_4",     "Noise in the fourth channel (alpha)" }
 
125
    { GIMP_PDB_FLOAT,    "noise-1",     "Noise in the first channel (red, gray)" },
 
126
    { GIMP_PDB_FLOAT,    "noise-2",     "Noise in the second channel (green, gray_alpha)" },
 
127
    { GIMP_PDB_FLOAT,    "noise-3",     "Noise in the third channel (blue)" },
 
128
    { GIMP_PDB_FLOAT,    "noise-4",     "Noise in the fourth channel (alpha)" }
132
129
  };
133
 
  static GimpParamDef noisify_args[] =
 
130
  static const GimpParamDef noisify_args[] =
134
131
  {
135
 
    { GIMP_PDB_INT32,    "run_mode",    "Interactive, non-interactive" },
 
132
    { GIMP_PDB_INT32,    "run-mode",    "Interactive, non-interactive" },
136
133
    { GIMP_PDB_IMAGE,    "image",       "Input image (unused)" },
137
134
    { GIMP_PDB_DRAWABLE, "drawable",    "Input drawable" },
138
135
    { GIMP_PDB_INT32,    "independent", "Noise in channels independent" },
139
 
    { GIMP_PDB_FLOAT,    "noise_1",     "Noise in the first channel (red, gray)" },
140
 
    { GIMP_PDB_FLOAT,    "noise_2",     "Noise in the second channel (green, gray_alpha)" },
141
 
    { GIMP_PDB_FLOAT,    "noise_3",     "Noise in the third channel (blue)" },
142
 
    { GIMP_PDB_FLOAT,    "noise_4",     "Noise in the fourth channel (alpha)" }
 
136
    { GIMP_PDB_FLOAT,    "noise-1",     "Noise in the first channel (red, gray)" },
 
137
    { GIMP_PDB_FLOAT,    "noise-2",     "Noise in the second channel (green, gray_alpha)" },
 
138
    { GIMP_PDB_FLOAT,    "noise-3",     "Noise in the third channel (blue)" },
 
139
    { GIMP_PDB_FLOAT,    "noise-4",     "Noise in the fourth channel (alpha)" }
143
140
  };
144
141
 
145
142
 
146
 
  gimp_install_procedure ("plug_in_scatter_rgb",
147
 
                          "Adds random noise to image channels ",
 
143
  gimp_install_procedure (RGB_NOISE_PROC,
 
144
                          N_("Distort colors by random amounts"),
148
145
                          "Add normally distributed (zero mean) random values "
149
146
                          "to image channels.  Noise may be additive "
150
147
                          "(uncorrelated) or multiplicative (correlated - "
154
151
                          "Torsten Martinsen",
155
152
                          "Torsten Martinsen",
156
153
                          "May 2000",
157
 
                          N_("_Scatter RGB..."),
 
154
                          N_("_RGB Noise..."),
158
155
                          "RGB*, GRAY*",
159
156
                          GIMP_PLUGIN,
160
157
                          G_N_ELEMENTS (scatter_args), 0,
161
158
                          scatter_args, NULL);
162
159
 
163
 
  gimp_plugin_menu_register ("plug_in_scatter_rgb", "<Image>/Filters/Noise");
 
160
  gimp_plugin_menu_register (RGB_NOISE_PROC, "<Image>/Filters/Noise");
164
161
 
165
 
  gimp_install_procedure ("plug_in_noisify",
 
162
  gimp_install_procedure (NOISIFY_PROC,
166
163
                          "Adds random noise to image channels ",
167
164
                          "Add normally distributed random values to "
168
165
                          "image channels. For colour images each "
213
210
    {
214
211
    case GIMP_RUN_INTERACTIVE:
215
212
      /*  Possibly retrieve data  */
216
 
      gimp_get_data ("plug_in_scatter_rgb", &nvals);
 
213
      gimp_get_data (RGB_NOISE_PROC, &nvals);
217
214
 
218
215
      /*  First acquire information with a dialog  */
219
216
      if (! noisify_dialog (drawable, drawable->bpp))
225
222
      break;
226
223
 
227
224
    case GIMP_RUN_NONINTERACTIVE:
228
 
      if (strcmp (name, "plug_in_noisify") == 0)
 
225
      if (strcmp (name, NOISIFY_PROC) == 0)
229
226
        {
230
227
          /*  Make sure all the arguments are there!  */
231
228
          if (nparams != 8)
243
240
              nvals.noise[3]    = param[7].data.d_float;
244
241
            }
245
242
        }
246
 
      else if (strcmp (name, "plug_in_scatter_rgb") == 0)
 
243
      else if (strcmp (name, RGB_NOISE_PROC) == 0)
247
244
        {
248
245
          if (nparams != 9)
249
246
            {
269
266
 
270
267
    case GIMP_RUN_WITH_LAST_VALS:
271
268
      /*  Possibly retrieve data  */
272
 
      gimp_get_data ("plug_in_scatter_rgb", &nvals);
 
269
      gimp_get_data (RGB_NOISE_PROC, &nvals);
273
270
      break;
274
271
 
275
272
    default:
282
279
 
283
280
  if (status == GIMP_PDB_SUCCESS)
284
281
    {
285
 
      gimp_progress_init (_("Adding Noise..."));
 
282
      gimp_progress_init (_("Adding noise"));
286
283
 
287
284
      /*  compute the luminosity which exceeds the luminosity threshold  */
288
285
      gimp_rgn_iterate2 (drawable, 0 /* unused */, noisify_func, noise_gr);
292
289
 
293
290
      /*  Store data  */
294
291
      if (run_mode == GIMP_RUN_INTERACTIVE)
295
 
        gimp_set_data ("plug_in_scatter_rgb", &nvals, sizeof (NoisifyVals));
 
292
        gimp_set_data (RGB_NOISE_PROC, &nvals, sizeof (NoisifyVals));
296
293
    }
297
294
  else
298
295
    {
397
394
 
398
395
  g_object_set_data (G_OBJECT (adj), "drawable", drawable);
399
396
 
400
 
  g_signal_connect (adj, "value_changed",
 
397
  g_signal_connect (adj, "value-changed",
401
398
                    G_CALLBACK (noisify_double_adjustment_update),
402
399
                    &nvals.noise[channel]);
403
 
  g_signal_connect_swapped (adj, "value_changed",
 
400
  g_signal_connect_swapped (adj, "value-changed",
404
401
                            G_CALLBACK (gimp_preview_invalidate),
405
402
                            preview);
406
403
 
424
421
 
425
422
  g_object_set_data (G_OBJECT (adj), "drawable", drawable);
426
423
 
427
 
  g_signal_connect (adj, "value_changed",
 
424
  g_signal_connect (adj, "value-changed",
428
425
                    G_CALLBACK (gimp_double_adjustment_update),
429
426
                    &nvals.noise[channel]);
430
 
  g_signal_connect_swapped (adj, "value_changed",
 
427
  g_signal_connect_swapped (adj, "value-changed",
431
428
                            G_CALLBACK (gimp_preview_invalidate),
432
429
                            preview);
433
430
 
446
443
  GtkWidget *table;
447
444
  gboolean   run;
448
445
 
449
 
  gimp_ui_init ("noisify", FALSE);
 
446
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
450
447
 
451
 
  dialog = gimp_dialog_new (_("Scatter RGB"), "noisify",
 
448
  dialog = gimp_dialog_new (_("RGB Noise"), PLUG_IN_BINARY,
452
449
                            NULL, 0,
453
 
                            gimp_standard_help_func, "plug-in-noisify",
 
450
                            gimp_standard_help_func, RGB_NOISE_PROC,
454
451
 
455
452
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
456
453
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
457
454
 
458
455
                            NULL);
459
456
 
 
457
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
458
                                           GTK_RESPONSE_OK,
 
459
                                           GTK_RESPONSE_CANCEL,
 
460
                                           -1);
 
461
 
 
462
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
463
 
460
464
  main_vbox = gtk_vbox_new (FALSE, 12);
461
465
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
462
466
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);