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

« back to all changes in this revision

Viewing changes to plug-ins/common/tiler.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
1
/* Tiler v0.31
2
2
 * 22 May 1997
3
3
 * Tim Rowley <tor@cs.brown.edu>
4
 
 */
5
 
 
6
 
/* TODO:
7
 
 * + better basis function
8
 
 */
9
 
 
10
 
/* History:
11
 
 * v0.1: initial version
12
 
 * v0.2: fix edge conditions
13
 
 * v0.3: port to 0.99 API
14
 
 * v0.31: small bugfix
 
4
 *
 
5
 * GIMP - The GNU Image Manipulation Program
 
6
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
21
 */
16
22
 
17
23
#include "config.h"
18
24
 
19
 
#include <stdio.h>
20
 
#include <stdlib.h>
21
25
#include <string.h>
22
26
 
23
27
#include <libgimp/gimp.h>
25
29
#include "libgimp/stdplugins-intl.h"
26
30
 
27
31
 
 
32
#define PLUG_IN_PROC "plug-in-make-seamless"
 
33
 
 
34
 
28
35
/* Declare local functions.
29
36
 */
30
37
static void query (void);
36
43
 
37
44
static void tile  (GimpDrawable     *drawable);
38
45
 
39
 
GimpPlugInInfo PLUG_IN_INFO =
 
46
const GimpPlugInInfo PLUG_IN_INFO =
40
47
{
41
48
  NULL,  /* init_proc  */
42
49
  NULL,  /* quit_proc  */
49
56
static void
50
57
query (void)
51
58
{
52
 
  static GimpParamDef args[] =
 
59
  static const GimpParamDef args[] =
53
60
  {
54
 
    { GIMP_PDB_INT32,    "run_mode", "Interactive, non-interactive" },
 
61
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive" },
55
62
    { GIMP_PDB_IMAGE,    "image",    "Input image (unused)" },
56
63
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }
57
64
  };
58
65
 
59
 
  gimp_install_procedure ("plug_in_make_seamless",
60
 
                          "Seamless tile creation",
 
66
  gimp_install_procedure (PLUG_IN_PROC,
 
67
                          N_("Alters edges to make the image seamlessly tileable"),
61
68
                          "This plugin creates a seamless tileable from "
62
69
                          "the input drawable",
63
70
                          "Tim Rowley",
69
76
                          G_N_ELEMENTS (args), 0,
70
77
                          args, NULL);
71
78
 
72
 
  gimp_plugin_menu_register ("plug_in_make_seamless", "<Image>/Filters/Map");
 
79
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Map");
73
80
}
74
81
 
75
82
 
130
137
  gdouble a = (ABS(x - width) - 1)/ (gdouble) (width - 1);
131
138
  gdouble b = (ABS(y - height) - 1) / (gdouble) (height - 1);
132
139
  gdouble w;
133
 
  guint i;
 
140
  guint   i;
134
141
 
135
142
  /* mimic ambiguous point handling in original algorithm */
136
143
  if (a < 1e-8 && b > 0.99999999)
147
154
static void
148
155
weld_pixels_alpha (guchar *dest1,
149
156
                   guchar *dest2,
150
 
                   gint width,
151
 
                   gint height,
152
 
                   gint x,
153
 
                   gint y,
154
 
                   guint bpp,
 
157
                   gint    width,
 
158
                   gint    height,
 
159
                   gint    x,
 
160
                   gint    y,
 
161
                   guint   bpp,
155
162
                   guchar *src1,
156
163
                   guchar *src2)
157
164
{
159
166
  gdouble b = (ABS(y - height) - 1) / (gdouble) (height - 1);
160
167
  gdouble w;
161
168
  gdouble alpha;
162
 
  guint ai = bpp-1;
163
 
  guint i;
 
169
  guint   ai = bpp-1;
 
170
  guint   i;
164
171
 
165
172
  /* mimic ambiguous point handling in original algorithm */
166
173
  if (a < 1e-8 && b > 0.99999999)
183
190
}
184
191
 
185
192
static void
186
 
tile_region (GimpDrawable *drawable, gboolean left,
187
 
             gint x1, gint y1, gint x2, gint y2)
 
193
tile_region (GimpDrawable *drawable,
 
194
             gboolean      left,
 
195
             gint          x1,
 
196
             gint          y1,
 
197
             gint          x2,
 
198
             gint          y2)
188
199
{
189
 
  glong      width, height;
190
 
  gint       bpp;
191
 
  gint       wodd, hodd;
192
 
  gint       w, h, x, y;
193
 
  gint       rgn1_x, rgn2_x, off_x;
194
 
  static gint progress = 0;
195
 
  gint       max_progress;
 
200
  glong         width, height;
 
201
  gint          bpp;
 
202
  gint          wodd, hodd;
 
203
  gint          w, h, x, y;
 
204
  gint          rgn1_x, rgn2_x, off_x;
 
205
  static gint   progress = 0;
 
206
  gint          max_progress;
196
207
  GimpPixelRgn  src1_rgn, src2_rgn, dest1_rgn, dest2_rgn;
197
 
  gpointer     pr;
198
 
  gboolean   has_alpha;
199
 
  guint      asymmetry_correction;
 
208
  gpointer      pr;
 
209
  gboolean      has_alpha;
 
210
  guint         asymmetry_correction;
200
211
 
201
212
  bpp = gimp_drawable_bpp (drawable->drawable_id);
202
213
  has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
210
221
  w = width / 2;
211
222
  h = height / 2;
212
223
 
213
 
  if (left) 
 
224
  if (left)
214
225
    {
215
226
      rgn1_x = x1;
216
227
      rgn2_x = x1 + w + wodd;
217
228
      off_x = w + wodd;
218
 
    } 
 
229
    }
219
230
  else
220
231
    {
221
232
      rgn1_x = x1 + w + wodd;
227
238
 
228
239
  gimp_pixel_rgn_init (&src1_rgn, drawable, rgn1_x, y1, w, h, FALSE, FALSE);
229
240
  gimp_pixel_rgn_init (&dest1_rgn, drawable, rgn1_x, y1, w, h, TRUE, TRUE);
230
 
  gimp_pixel_rgn_init (&src2_rgn, drawable, rgn2_x, y1 + h + hodd, 
 
241
  gimp_pixel_rgn_init (&src2_rgn, drawable, rgn2_x, y1 + h + hodd,
231
242
                       w, h, FALSE, FALSE);
232
 
  gimp_pixel_rgn_init (&dest2_rgn, drawable, rgn2_x, y1 + h + hodd, 
 
243
  gimp_pixel_rgn_init (&dest2_rgn, drawable, rgn2_x, y1 + h + hodd,
233
244
                       w, h, TRUE, TRUE);
234
245
 
235
246
  max_progress = width * height / 2;
243
254
      guchar *dest1 = dest1_rgn.data;
244
255
      guchar *src2  = src2_rgn.data;
245
256
      guchar *dest2 = dest2_rgn.data;
246
 
      gint row = src1_rgn.y - y1;
 
257
      gint   row    = src1_rgn.y - y1;
247
258
 
248
259
      for (y = 0; y < src1_rgn.h; y++, row++)
249
260
        {
283
294
          dest1 += dest1_rgn.rowstride;
284
295
          dest2 += dest2_rgn.rowstride;
285
296
        }
 
297
 
286
298
      progress += src1_rgn.w * src1_rgn.h;
287
299
      gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
288
300
    }
289
301
}
290
302
 
291
303
static void
292
 
copy_region (GimpDrawable *drawable, gint x, gint y, gint w, gint h)
 
304
copy_region (GimpDrawable *drawable,
 
305
             gint          x,
 
306
             gint          y,
 
307
             gint          w,
 
308
             gint          h)
293
309
{
294
 
  GimpPixelRgn  src_rgn, dest_rgn;
 
310
  GimpPixelRgn src_rgn, dest_rgn;
295
311
  gpointer     pr;
296
312
 
297
313
  gimp_pixel_rgn_init (&src_rgn, drawable, x, y, w, h, FALSE, FALSE);
315
331
static void
316
332
tile (GimpDrawable *drawable)
317
333
{
318
 
  glong      width, height;
319
 
  gint       x1, y1, x2, y2;
 
334
  glong width, height;
 
335
  gint  x1, y1, x2, y2;
320
336
 
321
337
  gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
322
 
  gimp_progress_init (_("Tiler..."));
323
 
  
 
338
  gimp_progress_init (_("Tiler"));
 
339
 
324
340
  height = y2 - y1;
325
341
  width = x2 - x1;
326
342