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

« back to all changes in this revision

Viewing changes to plug-ins/common/max_rgb.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20070502163303-6wchheivjxgjtlna
Tags: upstream-2.3.16
ImportĀ upstreamĀ versionĀ 2.3.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "config.h"
29
29
 
30
 
#include <stdio.h>
31
 
#include <stdlib.h>
32
 
 
33
 
#include <gtk/gtk.h>
34
 
 
35
30
#include <libgimp/gimp.h>
36
31
#include <libgimp/gimpui.h>
37
32
 
38
33
#include "libgimp/stdplugins-intl.h"
39
34
 
40
35
 
41
 
#define PLUG_IN_NAME "plug_in_max_rgb"
42
 
#define SHORT_NAME   "max_rgb"
43
 
#define HELP_ID      "plug-in-max-rgb"
 
36
#define PLUG_IN_PROC   "plug-in-max-rgb"
 
37
#define PLUG_IN_BINARY "max_rgb"
44
38
 
45
39
 
46
40
static void     query   (void);
55
49
 
56
50
static gint              max_rgb_dialog (GimpDrawable *drawable);
57
51
 
58
 
GimpPlugInInfo PLUG_IN_INFO =
 
52
const GimpPlugInInfo PLUG_IN_INFO =
59
53
{
60
54
  NULL,  /* init_proc  */
61
55
  NULL,  /* quit_proc  */
71
65
 
72
66
typedef struct
73
67
{
74
 
  gint     max_p;
75
 
  gboolean preview;
 
68
  gint max_p;
76
69
} ValueType;
77
70
 
78
71
static ValueType pvals =
79
72
{
80
 
  MAX_CHANNELS,
81
 
  TRUE
 
73
  MAX_CHANNELS
82
74
};
83
75
 
84
76
MAIN ()
86
78
static void
87
79
query (void)
88
80
{
89
 
  static GimpParamDef args [] =
 
81
  static const GimpParamDef args [] =
90
82
  {
91
 
    { GIMP_PDB_INT32,    "run_mode", "Interactive, non-interactive"       },
 
83
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive"       },
92
84
    { GIMP_PDB_IMAGE,    "image",    "Input image (not used)"             },
93
85
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable"                     },
94
 
    { GIMP_PDB_INT32,    "max_p",    "1 for maximizing, 0 for minimizing" }
 
86
    { GIMP_PDB_INT32,    "max-p",    "1 for maximizing, 0 for minimizing" }
95
87
  };
96
88
 
97
 
  gimp_install_procedure (PLUG_IN_NAME,
98
 
                          "Return an image in which each pixel holds only "
99
 
                          "the channel that has the maximum value in three "
100
 
                          "(red, green, blue) channels, and other channels "
101
 
                          "are zero-cleared",
102
 
                          "the help is not yet written for this plug-in since none is needed.",
 
89
  gimp_install_procedure (PLUG_IN_PROC,
 
90
                          N_("Reduce image to pure red, green, and blue"),
 
91
                          "There's no help yet.",
103
92
                          "Shuji Narazaki (narazaki@InetQ.or.jp)",
104
93
                          "Shuji Narazaki",
105
94
                          "May 2000",
106
 
                          N_("_Max RGB..."),
 
95
                          N_("Maxim_um RGB..."),
107
96
                          "RGB*",
108
97
                          GIMP_PLUGIN,
109
98
                          G_N_ELEMENTS (args), 0,
110
99
                          args, NULL);
111
100
 
112
 
  gimp_plugin_menu_register (PLUG_IN_NAME, "<Image>/Filters/Colors");
 
101
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Modify");
113
102
}
114
103
 
115
104
static void
138
127
  switch (run_mode)
139
128
    {
140
129
    case GIMP_RUN_INTERACTIVE:
141
 
      gimp_get_data (PLUG_IN_NAME, &pvals);
 
130
      gimp_get_data (PLUG_IN_PROC, &pvals);
142
131
      /* Since a channel might be selected, we must check wheter RGB or not. */
143
132
      if (!gimp_drawable_is_rgb (drawable->drawable_id))
144
133
        {
153
142
      pvals.max_p = param[3].data.d_int32;
154
143
      break;
155
144
    case GIMP_RUN_WITH_LAST_VALS:
156
 
      gimp_get_data (PLUG_IN_NAME, &pvals);
 
145
      gimp_get_data (PLUG_IN_PROC, &pvals);
157
146
      break;
158
147
    }
159
148
 
162
151
  if (run_mode != GIMP_RUN_NONINTERACTIVE)
163
152
    gimp_displays_flush ();
164
153
  if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
165
 
    gimp_set_data (PLUG_IN_NAME, &pvals, sizeof (ValueType));
 
154
    gimp_set_data (PLUG_IN_PROC, &pvals, sizeof (ValueType));
166
155
 
167
156
  values[0].data.d_status = status;
168
157
}
169
158
 
170
 
typedef struct {
171
 
  gint init_value;
172
 
  gint flag;
 
159
typedef struct
 
160
{
 
161
  gint     init_value;
 
162
  gint     flag;
173
163
  gboolean has_alpha;
174
164
} MaxRgbParam_t;
175
165
 
222
212
      guchar *src;
223
213
      gint    width, height, bpp;
224
214
 
225
 
      gimp_preview_get_size (preview, &width, &height);
226
 
      src = gimp_drawable_get_thumbnail_data (drawable->drawable_id,
227
 
                                              &width, &height, &bpp);
 
215
      src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
 
216
                                          &width, &height, &bpp);
228
217
 
229
218
      buffer = g_new (guchar, width * height * bpp);
230
219
 
242
231
    }
243
232
  else
244
233
    {
245
 
      gimp_progress_init ( _("Max RGB..."));
 
234
      gimp_progress_init (_("Max RGB"));
246
235
 
247
236
      gimp_rgn_iterate2 (drawable, 0 /* unused */, max_rgb_func, &param);
248
237
 
265
254
  GtkWidget *min;
266
255
  gboolean   run;
267
256
 
268
 
  gimp_ui_init ("max_rgb", TRUE);
 
257
  gimp_ui_init (PLUG_IN_BINARY, TRUE);
269
258
 
270
 
  dialog = gimp_dialog_new (_("Max RGB"), "max_rgb",
 
259
  dialog = gimp_dialog_new (_("Maximum RGB Value"), PLUG_IN_BINARY,
271
260
                            NULL, 0,
272
 
                            gimp_standard_help_func, "plug-in-max-rgb",
 
261
                            gimp_standard_help_func, PLUG_IN_PROC,
273
262
 
274
263
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
275
264
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
276
265
 
277
266
                            NULL);
278
267
 
 
268
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
269
                                           GTK_RESPONSE_OK,
 
270
                                           GTK_RESPONSE_CANCEL,
 
271
                                           -1);
 
272
 
 
273
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
274
 
279
275
  main_vbox = gtk_vbox_new (FALSE, 12);
280
276
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
281
277
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
282
278
  gtk_widget_show (main_vbox);
283
279
 
284
 
  preview = gimp_aspect_preview_new (drawable, &pvals.preview);
 
280
  preview = gimp_zoom_preview_new (drawable);
285
281
  gtk_box_pack_start_defaults (GTK_BOX (main_vbox), preview);
286
282
  gtk_widget_show (preview);
287
283
  g_signal_connect_swapped (preview, "invalidated",