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

« back to all changes in this revision

Viewing changes to plug-ins/rcm/rcm.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:
38
38
 
39
39
#include "config.h"
40
40
 
41
 
#include <stdio.h>
42
 
 
43
 
#include <gtk/gtk.h>
44
 
 
45
41
#include "libgimp/gimp.h"
 
42
#include "libgimp/gimpui.h"
46
43
 
47
44
#include "rcm.h"
48
45
#include "rcm_misc.h"
61
58
                    gint             *nreturn_vals,
62
59
                    GimpParam       **return_vals);
63
60
 
 
61
static void  rcm   (GimpDrawable     *drawable);
 
62
 
64
63
 
65
64
/* Global variables */
66
65
 
72
71
  GRAY_TO
73
72
};
74
73
 
75
 
GimpPlugInInfo PLUG_IN_INFO =
 
74
const GimpPlugInInfo PLUG_IN_INFO =
76
75
{
77
76
  NULL,    /* init_proc */
78
77
  NULL,    /* quit_proc */
80
79
  run,     /* run_proc */
81
80
};
82
81
 
 
82
 
83
83
MAIN()
84
84
 
85
85
 
90
90
{
91
91
  GimpParamDef args[] =
92
92
  {
93
 
    { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
94
 
    { GIMP_PDB_IMAGE, "image", "Input image (used for indexed images)" },
95
 
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
 
93
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive"          },
 
94
    { GIMP_PDB_IMAGE,    "image",    "Input image (used for indexed images)" },
 
95
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable"                        },
96
96
  };
97
97
 
98
 
  gimp_install_procedure ("plug_in_rotate_colormap",
99
 
                          "Colormap rotation as in xv",
 
98
  gimp_install_procedure (PLUG_IN_PROC,
 
99
                          N_("Replace a range of colors with another"),
100
100
                          "Exchanges two color ranges. "
101
101
                          "Based on code from Pavel Grinfeld (pavel@ml.com). "
102
102
                          "This version written by Sven Anders (anderss@fmi.uni-passau.de).",
103
103
                          "Sven Anders (anderss@fmi.uni-passau.de) and Pavel Grinfeld (pavel@ml.com)",
104
104
                          "Sven Anders (anderss@fmi.uni-passau.de)",
105
105
                          "04th April 1999",
106
 
                          N_("Colormap _Rotation..."),
 
106
                          N_("_Rotate Colors..."),
107
107
                          "RGB*",
108
108
                          GIMP_PLUGIN,
109
109
                          G_N_ELEMENTS (args), 0,
110
110
                          args, NULL);
111
111
 
112
 
  gimp_plugin_menu_register ("plug_in_rotate_colormap",
113
 
                             "<Image>/Filters/Colors/Map");
114
 
}
115
 
 
116
 
 
117
 
/* Rotate colormap of a single row */
118
 
 
119
 
void
 
112
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Map");
 
113
}
 
114
 
 
115
static void
 
116
run (const gchar      *name,
 
117
     gint              nparams,
 
118
     const GimpParam  *param,
 
119
     gint             *nreturn_vals,
 
120
     GimpParam       **return_vals)
 
121
{
 
122
  GimpParam         values[1];
 
123
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
 
124
 
 
125
  *nreturn_vals = 1;
 
126
  *return_vals  = values;
 
127
 
 
128
  INIT_I18N ();
 
129
 
 
130
  values[0].type          = GIMP_PDB_STATUS;
 
131
  values[0].data.d_status = status;
 
132
 
 
133
  Current.drawable = gimp_drawable_get (param[2].data.d_drawable);
 
134
  Current.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
 
135
 
 
136
  if (gimp_drawable_is_rgb (Current.drawable->drawable_id))
 
137
    {
 
138
      if (rcm_dialog ())
 
139
        {
 
140
          gimp_progress_init (_("Rotating the colors"));
 
141
 
 
142
          gimp_tile_cache_ntiles (2 * (Current.drawable->width /
 
143
                                       gimp_tile_width () + 1));
 
144
          rcm (Current.drawable);
 
145
          gimp_displays_flush ();
 
146
        }
 
147
      else
 
148
        {
 
149
          status = GIMP_PDB_CANCEL;
 
150
        }
 
151
    }
 
152
  else
 
153
    {
 
154
      status = GIMP_PDB_EXECUTION_ERROR;
 
155
    }
 
156
 
 
157
  values[0].data.d_status = status;
 
158
 
 
159
  if (status == GIMP_PDB_SUCCESS)
 
160
    gimp_drawable_detach (Current.drawable);
 
161
}
 
162
 
 
163
 
 
164
/* Rotate colors of a single row */
 
165
 
 
166
static void
120
167
rcm_row (const guchar *src_row,
121
168
         guchar       *dest_row,
122
169
         gint          row,
123
170
         gint          row_width,
124
171
         gint          bytes)
125
172
{
126
 
  gint    col, bytenum, skip;
127
 
  gdouble H, S, V;
128
 
  guchar  rgb[3];
 
173
  gint     col, bytenum;
 
174
  gdouble  H, S, V;
 
175
  guchar   rgb[3];
129
176
 
130
177
  for (col = 0; col < row_width; col++)
131
178
    {
132
 
      skip = 0;
 
179
      gboolean skip = FALSE;
133
180
 
134
181
      rgb[0] = src_row[col * bytes + 0];
135
182
      rgb[1] = src_row[col * bytes + 1];
149
196
                }
150
197
              else
151
198
                {
152
 
                  skip = 1;
 
199
                  skip = TRUE;
153
200
                }
154
201
            }
155
202
          else
156
203
            {
157
 
              skip = 1;
 
204
              skip = TRUE;
158
205
              gimp_hsv_to_rgb4 (rgb, Current.Gray->hue / TP,
159
206
                                Current.Gray->satur, V);
160
207
            }
162
209
 
163
210
      if (! skip)
164
211
        {
165
 
          H = rcm_linear( rcm_left_end (Current.From->angle),
 
212
          H = rcm_linear (rcm_left_end (Current.From->angle),
166
213
                          rcm_right_end (Current.From->angle),
167
214
                          rcm_left_end (Current.To->angle),
168
215
                          rcm_right_end (Current.To->angle),
185
232
}
186
233
 
187
234
 
188
 
/* Rotate colormap row by row ... */
 
235
/* Rotate colors row by row ... */
189
236
 
190
 
void
 
237
static void
191
238
rcm (GimpDrawable *drawable)
192
239
{
193
240
  GimpPixelRgn srcPR, destPR;
230
277
  g_free (src_row);
231
278
  g_free (dest_row);
232
279
}
233
 
 
234
 
 
235
 
/* STANDARD RUN */
236
 
 
237
 
static void
238
 
run (const gchar      *name,
239
 
     gint              nparams,
240
 
     const GimpParam  *param,
241
 
     gint             *nreturn_vals,
242
 
     GimpParam       **return_vals)
243
 
{
244
 
  GimpParam         values[1];
245
 
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
246
 
 
247
 
  *nreturn_vals = 1;
248
 
  *return_vals  = values;
249
 
 
250
 
  INIT_I18N ();
251
 
 
252
 
  values[0].type          = GIMP_PDB_STATUS;
253
 
  values[0].data.d_status = status;
254
 
 
255
 
  Current.drawable = gimp_drawable_get (param[2].data.d_drawable);
256
 
  Current.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
257
 
 
258
 
  /* works not on INDEXED images */
259
 
 
260
 
  if (gimp_drawable_is_indexed (Current.drawable->drawable_id) ||
261
 
      gimp_drawable_is_gray (Current.drawable->drawable_id) )
262
 
    {
263
 
      status = GIMP_PDB_EXECUTION_ERROR;
264
 
    }
265
 
  else
266
 
    {
267
 
      /* call dialog and rotate the colormap */
268
 
      if (gimp_drawable_is_rgb (Current.drawable->drawable_id) && rcm_dialog ())
269
 
        {
270
 
          gimp_progress_init (_("Rotating the colormap..."));
271
 
 
272
 
          gimp_tile_cache_ntiles (2 * (Current.drawable->width /
273
 
                                       gimp_tile_width () + 1));
274
 
          rcm (Current.drawable);
275
 
          gimp_displays_flush ();
276
 
        }
277
 
      else
278
 
        status = GIMP_PDB_EXECUTION_ERROR;
279
 
    }
280
 
 
281
 
  values[0].data.d_status = status;
282
 
 
283
 
  if (status == GIMP_PDB_SUCCESS)
284
 
    gimp_drawable_detach (Current.drawable);
285
 
}