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

« back to all changes in this revision

Viewing changes to plug-ins/common/cubism.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:
22
22
 
23
23
#include "config.h"
24
24
 
25
 
#include <stdlib.h>
26
25
#include <string.h>
27
26
 
28
 
#include <gtk/gtk.h>
29
 
 
30
27
#include <libgimp/gimp.h>
31
28
#include <libgimp/gimpui.h>
32
29
 
33
30
#include "libgimp/stdplugins-intl.h"
34
31
 
35
32
 
36
 
#define SCALE_WIDTH    125
37
 
#define BLACK            0
38
 
#define BG               1
39
 
#define SUPERSAMPLE      4
40
 
#define MAX_POINTS       4
41
 
#define MIN_ANGLE   -36000
42
 
#define MAX_ANGLE    36000
43
 
#define RANDOMNESS       5
 
33
#define PLUG_IN_PROC    "plug-in-cubism"
 
34
#define PLUG_IN_BINARY  "cubism"
 
35
 
 
36
#define SCALE_WIDTH     125
 
37
#define BLACK             0
 
38
#define BG                1
 
39
#define SUPERSAMPLE       4
 
40
#define MAX_POINTS        4
 
41
#define RANDOMNESS        5
 
42
 
44
43
 
45
44
typedef struct
46
45
{
119
118
  TRUE         /* preview         */
120
119
};
121
120
 
122
 
GimpPlugInInfo PLUG_IN_INFO =
 
121
const GimpPlugInInfo PLUG_IN_INFO =
123
122
{
124
123
  NULL,  /* init_proc  */
125
124
  NULL,  /* quit_proc  */
137
136
static void
138
137
query (void)
139
138
{
140
 
  static GimpParamDef args[] =
 
139
  static const GimpParamDef args[] =
141
140
  {
142
 
    { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
143
 
    { GIMP_PDB_IMAGE, "image", "Input image" },
144
 
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
145
 
    { GIMP_PDB_FLOAT, "tile_size", "Average diameter of each tile (in pixels)" },
146
 
    { GIMP_PDB_FLOAT, "tile_saturation", "Expand tiles by this amount" },
147
 
    { GIMP_PDB_INT32, "bg_color", "Background color: { BLACK (0), BG (1) }" }
 
141
    { GIMP_PDB_INT32,    "run-mode",        "Interactive, non-interactive" },
 
142
    { GIMP_PDB_IMAGE,    "image",           "Input image" },
 
143
    { GIMP_PDB_DRAWABLE, "drawable",        "Input drawable" },
 
144
    { GIMP_PDB_FLOAT,    "tile-size",       "Average diameter of each tile (in pixels)" },
 
145
    { GIMP_PDB_FLOAT,    "tile-saturation", "Expand tiles by this amount" },
 
146
    { GIMP_PDB_INT32,    "bg-color",        "Background color: { BLACK (0), BG (1) }" }
148
147
  };
149
148
 
150
 
  gimp_install_procedure ("plug_in_cubism",
151
 
                          "Convert the input drawable into a collection of rotated squares",
 
149
  gimp_install_procedure (PLUG_IN_PROC,
 
150
                          N_("Convert the image into randomly rotated square blobs"),
152
151
                          "Help not yet written for this plug-in",
153
152
                          "Spencer Kimball & Tracy Scott",
154
153
                          "Spencer Kimball & Tracy Scott",
159
158
                          G_N_ELEMENTS (args), 0,
160
159
                          args, NULL);
161
160
 
162
 
  gimp_plugin_menu_register ("plug_in_cubism", "<Image>/Filters/Artistic");
 
161
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Artistic");
163
162
}
164
163
 
165
164
static void
195
194
    {
196
195
    case GIMP_RUN_INTERACTIVE:
197
196
      /*  Possibly retrieve data  */
198
 
      gimp_get_data ("plug_in_cubism", &cvals);
 
197
      gimp_get_data (PLUG_IN_PROC, &cvals);
199
198
 
200
199
      /*  First acquire information with a dialog  */
201
200
      if (! cubism_dialog (drawable))
219
218
 
220
219
    case GIMP_RUN_WITH_LAST_VALS:
221
220
      /*  Possibly retrieve data  */
222
 
      gimp_get_data ("plug_in_cubism", &cvals);
 
221
      gimp_get_data (PLUG_IN_PROC, &cvals);
223
222
      break;
224
223
 
225
224
    default:
240
239
 
241
240
      /*  Store mvals data  */
242
241
      if (run_mode == GIMP_RUN_INTERACTIVE)
243
 
        gimp_set_data ("plug_in_cubism", &cvals, sizeof (CubismVals));
 
242
        gimp_set_data (PLUG_IN_PROC, &cvals, sizeof (CubismVals));
244
243
    }
245
244
  else if (status == GIMP_PDB_SUCCESS)
246
245
    {
264
263
  GtkObject *scale_data;
265
264
  gboolean   run;
266
265
 
267
 
  gimp_ui_init ("cubism", FALSE);
 
266
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
268
267
 
269
 
  dialog = gimp_dialog_new (_("Cubism"), "cubism",
 
268
  dialog = gimp_dialog_new (_("Cubism"), PLUG_IN_BINARY,
270
269
                            NULL, 0,
271
 
                            gimp_standard_help_func, "plug-in-cubism",
 
270
                            gimp_standard_help_func, PLUG_IN_PROC,
272
271
 
273
272
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
274
273
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
275
274
 
276
275
                            NULL);
277
276
 
 
277
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
278
                                           GTK_RESPONSE_OK,
 
279
                                           GTK_RESPONSE_CANCEL,
 
280
                                           -1);
 
281
 
 
282
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
283
 
278
284
  main_vbox = gtk_vbox_new (FALSE, 12);
279
285
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
280
286
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
299
305
                                     cvals.tile_size, 0.0, 100.0, 1.0, 10.0, 1,
300
306
                                     TRUE, 0, 0,
301
307
                                     NULL, NULL);
302
 
  g_signal_connect (scale_data, "value_changed",
 
308
  g_signal_connect (scale_data, "value-changed",
303
309
                    G_CALLBACK (gimp_double_adjustment_update),
304
310
                    &cvals.tile_size);
305
 
  g_signal_connect_swapped (scale_data, "value_changed",
 
311
  g_signal_connect_swapped (scale_data, "value-changed",
306
312
                            G_CALLBACK (gimp_preview_invalidate),
307
313
                            preview);
308
314
 
312
318
                          cvals.tile_saturation, 0.0, 10.0, 0.1, 1, 1,
313
319
                          TRUE, 0, 0,
314
320
                          NULL, NULL);
315
 
  g_signal_connect (scale_data, "value_changed",
 
321
  g_signal_connect (scale_data, "value-changed",
316
322
                    G_CALLBACK (gimp_double_adjustment_update),
317
323
                    &cvals.tile_saturation);
318
 
  g_signal_connect_swapped (scale_data, "value_changed",
 
324
  g_signal_connect_swapped (scale_data, "value-changed",
319
325
                            G_CALLBACK (gimp_preview_invalidate),
320
326
                            preview);
321
327
 
409
415
    }
410
416
  else
411
417
    {
412
 
      gimp_progress_init (_("Cubistic Transformation..."));
 
418
      gimp_progress_init (_("Cubistic transformation"));
413
419
      gimp_pixel_rgn_init (&src_rgn, drawable,
414
420
                           x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
415
421
 
525
531
                 guchar       *dest)
526
532
{
527
533
  GimpPixelRgn  src_rgn;
528
 
  gdouble       dmin_x, dmin_y;
529
 
  gdouble       dmax_x, dmax_y;
 
534
  gdouble       dmin_x = 0.0;
 
535
  gdouble       dmin_y = 0.0;
 
536
  gdouble       dmax_x = 0.0;
 
537
  gdouble       dmax_y = 0.0;
530
538
  gint          xs, ys;
531
539
  gint          xe, ye;
532
540
  gint          min_x, min_y;
557
565
  dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
558
566
  if (dist > 0.0)
559
567
    {
560
 
      one_over_dist = 1/dist;
 
568
      one_over_dist = 1.0 / dist;
561
569
      vec[0] = (ex - sx) * one_over_dist;
562
570
      vec[1] = (ey - sy) * one_over_dist;
563
571
    }
564
572
  else
565
 
    one_over_dist = 0.0;
 
573
    {
 
574
      one_over_dist = 0.0;
 
575
      vec[0] = 0.0;
 
576
      vec[1] = 0.0;
 
577
    }
566
578
 
567
579
  if (preview)
568
580
    {