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

« back to all changes in this revision

Viewing changes to plug-ins/common/color_enhance.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:
29
29
#include "libgimp/stdplugins-intl.h"
30
30
 
31
31
 
 
32
#define PLUG_IN_PROC "plug-in-color-enhance"
 
33
 
 
34
 
32
35
/* Declare local functions.
33
36
 */
34
37
static void   query                 (void);
38
41
                                     gint             *nreturn_vals,
39
42
                                     GimpParam       **return_vals);
40
43
 
41
 
static void   Color_Enhance         (GimpDrawable *drawable);
42
 
static void   indexed_Color_Enhance (gint32        image_ID);
43
 
 
44
 
 
45
 
GimpPlugInInfo PLUG_IN_INFO =
 
44
static void   Color_Enhance         (GimpDrawable     *drawable);
 
45
static void   indexed_Color_Enhance (gint32            image_ID);
 
46
 
 
47
 
 
48
const GimpPlugInInfo PLUG_IN_INFO =
46
49
{
47
50
  NULL,  /* init_proc  */
48
51
  NULL,  /* quit_proc  */
56
59
static void
57
60
query (void)
58
61
{
59
 
  static GimpParamDef args[] =
 
62
  static const GimpParamDef args[] =
60
63
  {
61
 
    { GIMP_PDB_INT32,    "run_mode", "Interactive, non-interactive" },
62
 
    { GIMP_PDB_IMAGE,    "image",    "Input image" },
63
 
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }
 
64
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive" },
 
65
    { GIMP_PDB_IMAGE,    "image",    "Input image"                  },
 
66
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable"               }
64
67
  };
65
68
 
66
 
  gimp_install_procedure ("plug_in_color_enhance",
67
 
                          "Automatically stretch the saturation of the "
68
 
                          "specified drawable to cover all possible ranges.",
 
69
  gimp_install_procedure (PLUG_IN_PROC,
 
70
                          N_("Stretch color saturation to cover maximum possible range"),
69
71
                          "This simple plug-in does an automatic saturation "
70
72
                          "stretch.  For each channel in the image, it finds "
71
73
                          "the minimum and maximum values... it uses those "
83
85
                          G_N_ELEMENTS (args), 0,
84
86
                          args, NULL);
85
87
 
86
 
  gimp_plugin_menu_register ("plug_in_color_enhance",
87
 
                             "<Image>/Layer/Colors/Auto");
 
88
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Auto");
88
89
}
89
90
 
90
91
static void
112
113
  if (gimp_drawable_is_rgb (drawable->drawable_id) ||
113
114
      gimp_drawable_is_gray (drawable->drawable_id))
114
115
    {
115
 
      gimp_progress_init (_("Color Enhance..."));
 
116
      gimp_progress_init (_("Color Enhance"));
116
117
      gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
117
118
      Color_Enhance (drawable);
118
119
 
132
133
    }
133
134
 
134
135
  *nreturn_vals = 1;
135
 
  *return_vals = values;
 
136
  *return_vals  = values;
136
137
 
137
 
  values[0].type = GIMP_PDB_STATUS;
 
138
  values[0].type          = GIMP_PDB_STATUS;
138
139
  values[0].data.d_status = status;
139
140
 
140
141
  gimp_drawable_detach (drawable);
144
145
get_v (const guchar *src)
145
146
{
146
147
  gdouble h, z, v;
147
 
  gint c, m, y;
148
 
  gint k;
149
 
  guchar map[3];
 
148
  gint    c, m, y;
 
149
  gint    k;
 
150
  guchar  map[3];
150
151
 
151
152
  c = 255 - src[0];
152
153
  m = 255 - src[1];
169
170
enhance_it (const guchar *src, guchar *dest, gdouble vlo, gdouble vhi)
170
171
{
171
172
  gdouble h, z, v;
172
 
  gint c, m, y;
173
 
  gint k;
174
 
  guchar map[3];
 
173
  gint    c, m, y;
 
174
  gint    k;
 
175
  guchar  map[3];
175
176
 
176
177
  c = 255 - src[0];
177
178
  m = 255 - src[1];
185
186
  map[1] = m - k;
186
187
  map[2] = y - k;
187
188
 
188
 
  gimp_rgb_to_hsv4(map, &h, &z, &v);
 
189
  gimp_rgb_to_hsv4 (map, &h, &z, &v);
189
190
 
190
191
  if (vhi != vlo)
191
192
    v = (v - vlo) / (vhi - vlo);
192
193
 
193
 
  gimp_hsv_to_rgb4(map, h, z, v);
 
194
  gimp_hsv_to_rgb4 (map, h, z, v);
194
195
 
195
196
  c = map[0];
196
197
  m = map[1];
212
213
indexed_Color_Enhance (gint32 image_ID)
213
214
{
214
215
  guchar *cmap;
215
 
  gint ncols,i;
 
216
  gint    ncols,i;
216
217
  gdouble vhi = 0.0, vlo = 1.0;
217
218
 
218
219
  cmap = gimp_image_get_colormap (image_ID, &ncols);
239
240
  gimp_image_set_colormap (image_ID, cmap, ncols);
240
241
}
241
242
 
242
 
typedef struct {
243
 
  gdouble vhi;
244
 
  gdouble vlo;
 
243
typedef struct
 
244
{
 
245
  gdouble  vhi;
 
246
  gdouble  vlo;
245
247
  gboolean has_alpha;
246
248
} ColorEnhanceParam_t;
247
249