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

« back to all changes in this revision

Viewing changes to plug-ins/common/retinex.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
20
20
 
21
21
#include <string.h>
22
22
 
23
 
#include <gtk/gtk.h>
24
 
 
25
23
#include "libgimp/gimp.h"
26
24
#include "libgimp/gimpui.h"
27
25
 
28
26
#include "libgimp/stdplugins-intl.h"
29
27
 
30
28
 
 
29
#define PLUG_IN_PROC        "plug-in-retinex"
 
30
#define PLUG_IN_BINARY      "retinex"
31
31
#define MAX_RETINEX_SCALES    8
32
32
#define MIN_GAUSSIAN_SCALE   16
33
33
#define MAX_GAUSSIAN_SCALE  250
41
41
  gint     nscales;
42
42
  gint     scales_mode;
43
43
  gfloat   cvar;
44
 
  gboolean preview;
45
44
} RetinexParams;
46
45
 
47
46
typedef enum
126
125
  240,             /* Scale */
127
126
  3,               /* Scales */
128
127
  RETINEX_UNIFORM, /* Echelles reparties uniformement */
129
 
  1.2,             /* A voir */
130
 
  TRUE             /* default is to update the preview */
 
128
  1.2              /* A voir */
131
129
};
132
130
 
133
131
static GimpPlugInInfo PLUG_IN_INFO =
143
141
static void
144
142
query (void)
145
143
{
146
 
  static GimpParamDef args[] =
 
144
  static const GimpParamDef args[] =
147
145
  {
148
 
    { GIMP_PDB_INT32,    "run_mode",    "Interactive, non-interactive"        },
 
146
    { GIMP_PDB_INT32,    "run-mode",    "Interactive, non-interactive"        },
149
147
    { GIMP_PDB_IMAGE,    "image",       "Input image (unused)"                },
150
148
    { GIMP_PDB_DRAWABLE, "drawable",    "Input drawable"                      },
151
149
    { GIMP_PDB_INT32,    "scale",       "Biggest scale value"                 },
152
150
    { GIMP_PDB_INT32,    "nscales",     "Number of scales"                    },
153
 
    { GIMP_PDB_INT32,    "scales_mode", "Retinex distribution through scales" },
 
151
    { GIMP_PDB_INT32,    "scales-mode", "Retinex distribution through scales" },
154
152
    { GIMP_PDB_FLOAT,    "cvar",        "Variance value"                      }
155
153
  };
156
154
 
157
 
  gimp_install_procedure ("plug_in_retinex",
158
 
                          "Retinex Image Enhancement Algorithm",
 
155
  gimp_install_procedure (PLUG_IN_PROC,
 
156
                          N_("Enhance contrast using the Retinex method"),
159
157
                          "The Retinex Image Enhancement Algorithm is an "
160
158
                          "automatic image enhancement method that enhances "
161
159
                          "a digital image in terms of dynamic range "
165
163
                          "Fabien Pelisson",
166
164
                          "Fabien Pelisson",
167
165
                          "2003",
168
 
                          N_("_Retinex..."),
 
166
                          N_("Retine_x..."),
169
167
                          "RGB*",
170
168
                          GIMP_PLUGIN,
171
169
                          G_N_ELEMENTS (args), 0,
172
170
                          args, NULL);
173
171
 
174
 
  gimp_plugin_menu_register ("plug_in_retinex", "<Image>/Filters/Colors");
 
172
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Modify");
175
173
}
176
174
 
177
175
static void
216
214
    {
217
215
    case GIMP_RUN_INTERACTIVE:
218
216
      /*  Possibly retrieve data  */
219
 
      gimp_get_data ("plug_in_retinex", &rvals);
 
217
      gimp_get_data (PLUG_IN_PROC, &rvals);
 
218
 
220
219
      /*  First acquire information with a dialog  */
221
220
      if (! retinex_dialog (drawable))
222
221
        return;
238
237
      break;
239
238
 
240
239
    case GIMP_RUN_WITH_LAST_VALS:
241
 
      gimp_get_data ("plug_in_retinex", &rvals);
 
240
      gimp_get_data (PLUG_IN_PROC, &rvals);
242
241
      break;
243
242
 
244
243
    default:
248
247
  if ((status == GIMP_PDB_SUCCESS) &&
249
248
      (gimp_drawable_is_rgb (drawable->drawable_id)))
250
249
    {
251
 
      gimp_progress_init (_("Retinex..."));
 
250
      gimp_progress_init (_("Retinex"));
 
251
 
252
252
      retinex (drawable, NULL);
253
 
      gimp_progress_init (_("Retinex (4/4): updated..."));
254
253
 
255
254
      if (run_mode != GIMP_RUN_NONINTERACTIVE)
256
255
        gimp_displays_flush ();
257
256
 
258
257
      /*  Store data  */
259
258
      if (run_mode == GIMP_RUN_INTERACTIVE)
260
 
        gimp_set_data ("plug_in_retinex", &rvals, sizeof (RetinexParams));
 
259
        gimp_set_data (PLUG_IN_PROC, &rvals, sizeof (RetinexParams));
261
260
    }
262
261
  else
263
262
    {
285
284
  GtkWidget *frame;
286
285
  gboolean   run;
287
286
 
288
 
  gimp_ui_init ("retinex", FALSE);
 
287
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
289
288
 
290
 
  dialog = gimp_dialog_new (_("Retinex Image Enhancement"), "retinex",
 
289
  dialog = gimp_dialog_new (_("Retinex Image Enhancement"), PLUG_IN_BINARY,
291
290
                            NULL, 0,
292
 
                            gimp_standard_help_func, "plug-in-retinex",
 
291
                            gimp_standard_help_func, PLUG_IN_PROC,
 
292
 
293
293
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
294
294
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
295
295
 
296
296
                            NULL);
297
297
 
 
298
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
299
                                           GTK_RESPONSE_OK,
 
300
                                           GTK_RESPONSE_CANCEL,
 
301
                                           -1);
 
302
 
 
303
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
304
 
298
305
  main_vbox = gtk_vbox_new (FALSE, 12);
299
306
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
300
307
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
301
308
  gtk_widget_show (main_vbox);
302
309
 
303
 
  preview = gimp_aspect_preview_new (drawable, &rvals.preview);
 
310
  preview = gimp_zoom_preview_new (drawable);
304
311
  gtk_box_pack_start_defaults (GTK_BOX (main_vbox), preview);
305
312
  gtk_widget_show (preview);
306
313
 
348
355
  scrollbar = GIMP_SCALE_ENTRY_SCALE (adj);
349
356
  gtk_range_set_update_policy (GTK_RANGE (scrollbar), GTK_UPDATE_DISCONTINUOUS);
350
357
 
351
 
  g_signal_connect (adj, "value_changed",
 
358
  g_signal_connect (adj, "value-changed",
352
359
                    G_CALLBACK (gimp_int_adjustment_update),
353
360
                    &rvals.scale);
354
 
  g_signal_connect_swapped (adj, "value_changed",
 
361
  g_signal_connect_swapped (adj, "value-changed",
355
362
                            G_CALLBACK (gimp_preview_invalidate),
356
363
                            preview);
357
364
 
363
370
  scrollbar = GIMP_SCALE_ENTRY_SCALE (adj);
364
371
  gtk_range_set_update_policy (GTK_RANGE (scrollbar), GTK_UPDATE_DISCONTINUOUS);
365
372
 
366
 
  g_signal_connect (adj, "value_changed",
 
373
  g_signal_connect (adj, "value-changed",
367
374
                    G_CALLBACK (gimp_int_adjustment_update),
368
375
                    &rvals.nscales);
369
 
  g_signal_connect_swapped (adj, "value_changed",
 
376
  g_signal_connect_swapped (adj, "value-changed",
370
377
                            G_CALLBACK (gimp_preview_invalidate),
371
378
                            preview);
372
379
 
377
384
  scrollbar = GIMP_SCALE_ENTRY_SCALE (adj);
378
385
  gtk_range_set_update_policy (GTK_RANGE (scrollbar), GTK_UPDATE_DISCONTINUOUS);
379
386
 
380
 
  g_signal_connect (adj, "value_changed",
 
387
  g_signal_connect (adj, "value-changed",
381
388
                    G_CALLBACK (gimp_float_adjustment_update),
382
389
                    &rvals.cvar);
383
 
  g_signal_connect_swapped (adj, "value_changed",
 
390
  g_signal_connect_swapped (adj, "value-changed",
384
391
                            G_CALLBACK (gimp_preview_invalidate),
385
392
                            preview);
386
393
 
413
420
   */
414
421
  if (preview)
415
422
    {
416
 
      gimp_preview_get_size (preview, &width, &height);
417
 
      src = gimp_drawable_get_thumbnail_data (drawable->drawable_id,
418
 
                                              &width, &height, &bytes);
 
423
      src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
 
424
                                          &width, &height, &bytes);
419
425
    }
420
426
  else
421
427
    {
645
651
 
646
652
  if (!preview_mode)
647
653
    {
648
 
      gimp_progress_init (_("Retinex: Filtering..."));
 
654
      gimp_progress_init (_("Retinex: filtering"));
649
655
      max_preview = 3 * rvals.nscales;
650
656
    }
651
657