28
28
#include "config.h"
35
30
#include <libgimp/gimp.h>
36
31
#include <libgimp/gimpui.h>
38
33
#include "libgimp/stdplugins-intl.h"
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"
46
40
static void query (void);
89
static GimpParamDef args [] =
81
static const GimpParamDef args [] =
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" }
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 "
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)",
95
N_("Maxim_um RGB..."),
109
98
G_N_ELEMENTS (args), 0,
112
gimp_plugin_menu_register (PLUG_IN_NAME, "<Image>/Filters/Colors");
101
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Modify");
138
127
switch (run_mode)
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))
153
142
pvals.max_p = param[3].data.d_int32;
155
144
case GIMP_RUN_WITH_LAST_VALS:
156
gimp_get_data (PLUG_IN_NAME, &pvals);
145
gimp_get_data (PLUG_IN_PROC, &pvals);
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));
167
156
values[0].data.d_status = status;
173
163
gboolean has_alpha;
223
213
gint width, height, bpp;
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);
229
218
buffer = g_new (guchar, width * height * bpp);
245
gimp_progress_init ( _("Max RGB..."));
234
gimp_progress_init (_("Max RGB"));
247
236
gimp_rgn_iterate2 (drawable, 0 /* unused */, max_rgb_func, ¶m);
268
gimp_ui_init ("max_rgb", TRUE);
257
gimp_ui_init (PLUG_IN_BINARY, TRUE);
270
dialog = gimp_dialog_new (_("Max RGB"), "max_rgb",
259
dialog = gimp_dialog_new (_("Maximum RGB Value"), PLUG_IN_BINARY,
272
gimp_standard_help_func, "plug-in-max-rgb",
261
gimp_standard_help_func, PLUG_IN_PROC,
274
263
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
275
264
GTK_STOCK_OK, GTK_RESPONSE_OK,
268
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
273
gimp_window_set_transient (GTK_WINDOW (dialog));
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);
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",