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

« back to all changes in this revision

Viewing changes to plug-ins/sel2path/edge.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
/* edge.c: operations on edges in bitmaps.
2
 
 
3
 
Copyright (C) 1992 Free Software Foundation, Inc.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify
6
 
it under the terms of the GNU General Public License as published by
7
 
the Free Software Foundation; either version 2, or (at your option)
8
 
any later version.
9
 
 
10
 
This program is distributed in the hope that it will be useful,
11
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
GNU General Public License for more details.
14
 
 
15
 
You should have received a copy of the GNU General Public License
16
 
along with this program; if not, write to the Free Software
17
 
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
2
 *
 
3
 * Copyright (C) 1992 Free Software Foundation, Inc.
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2, or (at your option)
 
8
 * any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 */
18
19
 
19
20
#include "config.h"
20
21
 
40
41
static edge_type next_edge (edge_type);
41
42
 
42
43
/* The following macros are used (directly or indirectly) by the
43
 
   `next_outline_edge' routine.  */ 
 
44
   `next_outline_edge' routine.  */
44
45
 
45
46
/* Given the direction DIR of the pixel to test, decide which edge on
46
47
   that pixel we are supposed to test.  Because we've chosen the mapping
53
54
  `COL').   We are in the ``display'' coordinate system, with y
54
55
  increasing downward and x increasing to the right.  Therefore, we are
55
56
  implementing the following table:
56
 
  
 
57
 
57
58
  direction  row delta  col delta
58
 
    north       -1          0  
 
59
    north       -1          0
59
60
    south       +1          0
60
61
    east         0         +1
61
62
    west         0         +1
62
 
    
 
63
 
63
64
  with the other four directions (e.g., northwest) being the sum of
64
65
  their components (e.g., north + west).
65
 
  
 
66
 
66
67
  The first macro, `COMPUTE_DELTA', handles splitting up the latter
67
68
  cases, all of which have been assigned odd numbers.  */
68
 
  
 
69
 
69
70
#define COMPUTE_DELTA(axis, dir)                                        \
70
71
  ((dir) % 2 != 0                                                       \
71
72
    ? COMPUTE_##axis##_DELTA ((dir) - 1)                                \
109
110
   on the current pixel.  We want to go around outside outlines
110
111
   counterclockwise, and inside outlines clockwise (because that is how
111
112
   both Metafont and Adobe Type 1 format want their curves to be drawn).
112
 
   
 
113
 
113
114
   The very first outline (an outside one) on each character starts on a
114
115
   top edge (STARTING_EDGE in edge.h defines this); so, if we're at a
115
116
   top edge, we want to go only to the left (on the pixel to the west)
116
117
   or down (on the same pixel), to begin with.  Then, when we're on a
117
118
   left edge, we want to go to the top edge (on the southwest pixel) or
118
119
   to the left edge (on the south pixel).
119
 
   
 
120
 
120
121
   All well and good. But if you draw a rasterized circle (or whatever),
121
122
   eventually we have to come back around to the beginning; at that
122
123
   point, we'll be on a top edge, and we'll have to go to the right edge
123
124
   on the northwest pixel.  Draw pictures.
124
 
   
 
125
 
125
126
   The upshot is, if we find an edge on another pixel, we return (in ROW
126
127
   and COL) the position of the new pixel, and (in EDGE) the kind of
127
128
   edge it is.  If we don't find such an edge, we return (in EDGE) the
133
134
{
134
135
  unsigned original_row = *row;
135
136
  unsigned original_col = *col;
136
 
  
 
137
 
137
138
  switch (*edge)
138
139
    {
139
140
    case right:
215
216
      return row == 0 || sel_pixel_is_white(row - 1, col);
216
217
 
217
218
    case right:
218
 
      return (col ==  sel_get_width() - 1) 
 
219
      return (col ==  sel_get_width() - 1)
219
220
        || sel_pixel_is_white(row, col + 1);
220
221
 
221
222
    case bottom:
222
 
      return (row ==  sel_get_height() - 1) 
 
223
      return (row ==  sel_get_height() - 1)
223
224
        || sel_pixel_is_white(row + 1, col);
224
 
 
 
225
 
225
226
    case no_edge:
226
227
    default:
227
228
      printf ("is_outline_edge: Bad edge value(%d)", edge);
228
229
    }
229
 
  
 
230
 
230
231
  return 0; /* NOTREACHED */
231
232
}
232
233