1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include <glib-object.h>
25
#include "vectors-types.h"
27
#include "base/temp-buf.h"
29
#include "core/gimpimage.h"
31
#include "gimpstroke.h"
32
#include "gimpvectors.h"
33
#include "gimpvectors-preview.h"
36
/* public functions */
39
gimp_vectors_get_new_preview (GimpViewable *viewable,
45
GimpStroke *cur_stroke;
46
gdouble xscale, yscale;
49
guchar white[1] = { 255 };
51
vectors = GIMP_VECTORS (viewable);
52
item = GIMP_ITEM (viewable);
54
xscale = ((gdouble) width) / gimp_image_get_width (item->gimage);
55
yscale = ((gdouble) height) / gimp_image_get_height (item->gimage);
57
temp_buf = temp_buf_new (width, height, 1, 0, 0, white);
58
data = temp_buf_data (temp_buf);
60
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
62
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
68
coords = gimp_stroke_interpolate (cur_stroke, 0.5, &closed);
72
for (i = 0; i < coords->len; i++)
77
point = g_array_index (coords, GimpCoords, i);
79
x = ROUND (point.x * xscale);
80
y = ROUND (point.y * yscale);
82
if (x >= 0 && y >= 0 && x < width && y < height)
83
data[y * width + x] = 0;
86
g_array_free (coords, TRUE);