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

« back to all changes in this revision

Viewing changes to plug-ins/common/colorify.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
 * Colorify. Changes the pixel's luminosity to a specified color
27
27
#include "libgimp/stdplugins-intl.h"
28
28
 
29
29
 
30
 
#define PLUG_IN_NAME    "plug_in_colorify"
 
30
#define PLUG_IN_PROC    "plug-in-colorify"
 
31
#define PLUG_IN_BINARY  "colorify"
31
32
#define PLUG_IN_VERSION "1.1"
32
 
#define HELP_ID         "plug-in-colorify"
33
33
 
34
34
#define COLOR_SIZE 30
35
35
 
49
49
typedef struct
50
50
{
51
51
  GimpRGB  color;
52
 
  gboolean preview;
53
52
} ColorifyVals;
54
53
 
55
54
static ColorifyVals cvals =
56
55
{
57
 
  { 1.0, 1.0, 1.0, 1.0 },
58
 
  TRUE
 
56
  { 1.0, 1.0, 1.0, 1.0 }
59
57
};
60
58
 
61
59
static GimpRGB button_color[] =
69
67
  { 1.0, 1.0, 1.0, 1.0 },
70
68
};
71
69
 
72
 
GimpPlugInInfo PLUG_IN_INFO =
 
70
const GimpPlugInInfo PLUG_IN_INFO =
73
71
{
74
72
  NULL,
75
73
  NULL,
92
90
static void
93
91
query (void)
94
92
{
95
 
  static GimpParamDef args[] =
 
93
  static const GimpParamDef args[] =
96
94
  {
97
 
    { GIMP_PDB_INT32,    "run_mode", "Interactive, non-interactive" },
98
 
    { GIMP_PDB_IMAGE,    "image",    "Input image" },
99
 
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
100
 
    { GIMP_PDB_COLOR,    "color",    "Color to apply"}
 
95
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive" },
 
96
    { GIMP_PDB_IMAGE,    "image",    "Input image"                  },
 
97
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable"               },
 
98
    { GIMP_PDB_COLOR,    "color",    "Color to apply"               }
101
99
  };
102
100
 
103
 
  gimp_install_procedure (PLUG_IN_NAME,
104
 
                          "Similar to the \"Color\" mode for layers.",
 
101
  gimp_install_procedure (PLUG_IN_PROC,
 
102
                          N_("Replace all colors with shades of a specified color"),
105
103
                          "Makes an average of the RGB channels and uses it "
106
104
                          "to set the color",
107
105
                          "Francisco Bustamante",
108
106
                          "Francisco Bustamante",
109
107
                          PLUG_IN_VERSION,
110
 
                          N_("_Colorify..."),
 
108
                          N_("Colorif_y..."),
111
109
                          "RGB*",
112
110
                          GIMP_PLUGIN,
113
111
                          G_N_ELEMENTS (args), 0,
114
112
                          args, NULL);
115
113
 
116
 
  gimp_plugin_menu_register (PLUG_IN_NAME, "<Image>/Filters/Colors");
 
114
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Modify");
117
115
}
118
116
 
119
117
static void
144
142
  switch (run_mode)
145
143
    {
146
144
    case GIMP_RUN_INTERACTIVE:
147
 
      gimp_get_data (PLUG_IN_NAME, &cvals);
 
145
      gimp_get_data (PLUG_IN_PROC, &cvals);
148
146
      if (!colorify_dialog (drawable))
149
147
        return;
150
148
      break;
159
157
 
160
158
    case GIMP_RUN_WITH_LAST_VALS:
161
159
      /*  Possibly retrieve data  */
162
 
      gimp_get_data (PLUG_IN_NAME, &cvals);
 
160
      gimp_get_data (PLUG_IN_PROC, &cvals);
163
161
      break;
164
162
 
165
163
    default:
168
166
 
169
167
  if (status == GIMP_PDB_SUCCESS)
170
168
    {
171
 
      gimp_progress_init (_("Colorifying..."));
 
169
      gimp_progress_init (_("Colorifying"));
172
170
 
173
171
      colorify (drawable, NULL);
174
172
 
175
173
      if (run_mode == GIMP_RUN_INTERACTIVE)
176
 
        gimp_set_data (PLUG_IN_NAME, &cvals, sizeof (ColorifyVals));
 
174
        gimp_set_data (PLUG_IN_PROC, &cvals, sizeof (ColorifyVals));
177
175
 
178
176
      if (run_mode != GIMP_RUN_NONINTERACTIVE)
179
177
        gimp_displays_flush ();
212
210
 
213
211
  for (i = 0; i < 256; i ++)
214
212
    {
215
 
      lum_red_lookup[i]     = i * GIMP_RGB_INTENSITY_RED;
216
 
      lum_green_lookup[i]   = i * GIMP_RGB_INTENSITY_GREEN;
217
 
      lum_blue_lookup[i]    = i * GIMP_RGB_INTENSITY_BLUE;
 
213
      lum_red_lookup[i]     = i * GIMP_RGB_LUMINANCE_RED;
 
214
      lum_green_lookup[i]   = i * GIMP_RGB_LUMINANCE_GREEN;
 
215
      lum_blue_lookup[i]    = i * GIMP_RGB_LUMINANCE_BLUE;
218
216
      final_red_lookup[i]   = i * cvals.color.r;
219
217
      final_green_lookup[i] = i * cvals.color.g;
220
218
      final_blue_lookup[i]  = i * cvals.color.b;
225
223
      gint    width, height, bytes;
226
224
      guchar *src;
227
225
 
228
 
      gimp_preview_get_size (preview, &width, &height);
229
 
      src = gimp_drawable_get_thumbnail_data (drawable->drawable_id,
230
 
                                              &width, &height, &bytes);
 
226
      src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
 
227
                                        &width, &height, &bytes);
231
228
      for (i = 0; i < width * height; i++)
232
229
        colorify_func (src + i * bytes, src + i * bytes, bytes, NULL);
233
230
 
253
250
  gint       i;
254
251
  gboolean   run;
255
252
 
256
 
  gimp_ui_init ("colorify", TRUE);
 
253
  gimp_ui_init (PLUG_IN_BINARY, TRUE);
257
254
 
258
 
  dialog = gimp_dialog_new (_("Colorify"), "colorify",
 
255
  dialog = gimp_dialog_new (_("Colorify"), PLUG_IN_BINARY,
259
256
                            NULL, 0,
260
 
                            gimp_standard_help_func, HELP_ID,
 
257
                            gimp_standard_help_func, PLUG_IN_PROC,
261
258
 
262
259
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
263
260
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
264
261
 
265
262
                            NULL);
266
263
 
 
264
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
265
                                           GTK_RESPONSE_OK,
 
266
                                           GTK_RESPONSE_CANCEL,
 
267
                                           -1);
 
268
 
 
269
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
270
 
267
271
  main_vbox = gtk_vbox_new (FALSE, 12);
268
272
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
269
273
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
270
274
  gtk_widget_show (main_vbox);
271
275
 
272
 
  preview = gimp_aspect_preview_new (drawable, &cvals.preview);
 
276
  preview = gimp_zoom_preview_new (drawable);
273
277
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
274
278
  gtk_widget_show (preview);
275
279
  g_signal_connect_swapped (preview, "invalidated",
282
286
  gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
283
287
  gtk_widget_show (table);
284
288
 
285
 
  label = gtk_label_new (_("Custom Color:"));
 
289
  label = gtk_label_new (_("Custom color:"));
286
290
  gtk_table_attach (GTK_TABLE (table), label, 4, 6, 0, 1,
287
291
                    GTK_FILL, GTK_FILL, 0, 0);
288
292
  gtk_widget_show (label);
291
295
                                               COLOR_SIZE, COLOR_SIZE,
292
296
                                               &cvals.color,
293
297
                                               GIMP_COLOR_AREA_FLAT);
294
 
  g_signal_connect (custom_color_button, "color_changed",
 
298
  g_signal_connect (custom_color_button, "color-changed",
295
299
                    G_CALLBACK (gimp_color_button_get_color),
296
300
                    &cvals.color);
297
 
  g_signal_connect_swapped (custom_color_button, "color_changed",
 
301
  g_signal_connect_swapped (custom_color_button, "color-changed",
298
302
                            G_CALLBACK (gimp_preview_invalidate),
299
303
                            preview);
300
304