2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-09-21 03:58:26 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdrawable-stroke.c
|
|
|
|
* Copyright (C) 2003 Simon Budig <simon@gimp.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
#include "base/boundary.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
|
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
2003-10-01 02:06:19 +08:00
|
|
|
#include "gimpchannel.h"
|
2003-09-30 07:45:06 +08:00
|
|
|
#include "gimpcontext.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "gimpdrawable-stroke.h"
|
|
|
|
#include "gimpimage.h"
|
2003-09-28 04:04:07 +08:00
|
|
|
#include "gimppattern.h"
|
|
|
|
#include "gimpscanconvert.h"
|
|
|
|
#include "gimpstrokeoptions.h"
|
|
|
|
#include "gimpunit.h"
|
|
|
|
|
|
|
|
#include "vectors/gimpstroke.h"
|
|
|
|
#include "vectors/gimpvectors.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
static GimpScanConvert * gimp_drawable_render_boundary (GimpDrawable *drawable,
|
|
|
|
const BoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
|
|
|
static GimpScanConvert * gimp_drawable_render_vectors (GimpDrawable *drawable,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean do_stroke);
|
|
|
|
static void gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpScanConvert *scan_convert,
|
|
|
|
gboolean do_stroke,
|
|
|
|
gboolean push_undo);
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2003-09-30 10:44:17 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_fill_boundary (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
const BoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
|
|
|
|
g_return_if_fail (bound_segs == NULL || n_bound_segs != 0);
|
|
|
|
g_return_if_fail (options->style != GIMP_FILL_STYLE_PATTERN ||
|
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_boundary (drawable,
|
|
|
|
bound_segs, n_bound_segs,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, options,
|
|
|
|
scan_convert, FALSE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-30 10:44:17 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_stroke_boundary (GimpDrawable *drawable,
|
|
|
|
GimpStrokeOptions *options,
|
|
|
|
const BoundSeg *bound_segs,
|
2003-09-30 23:16:51 +08:00
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
2008-10-25 19:59:03 +08:00
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
2003-09-30 10:44:17 +08:00
|
|
|
{
|
2003-09-30 23:16:51 +08:00
|
|
|
GimpScanConvert *scan_convert;
|
2008-10-25 21:12:48 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
|
|
|
|
g_return_if_fail (bound_segs == NULL || n_bound_segs != 0);
|
|
|
|
g_return_if_fail (GIMP_FILL_OPTIONS (options)->style != GIMP_FILL_STYLE_PATTERN ||
|
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_boundary (drawable,
|
|
|
|
bound_segs, n_bound_segs,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, GIMP_FILL_OPTIONS (options),
|
|
|
|
scan_convert, TRUE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_fill_vectors (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_FILL_OPTIONS (options));
|
|
|
|
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
|
|
|
g_return_if_fail (options->style != GIMP_FILL_STYLE_PATTERN ||
|
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_vectors (drawable, vectors, FALSE);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, options,
|
|
|
|
scan_convert, FALSE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_stroke_vectors (GimpDrawable *drawable,
|
|
|
|
GimpStrokeOptions *options,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
|
|
|
|
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
|
|
|
g_return_if_fail (GIMP_FILL_OPTIONS (options)->style != GIMP_FILL_STYLE_PATTERN ||
|
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_vectors (drawable, vectors, TRUE);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, GIMP_FILL_OPTIONS (options),
|
|
|
|
scan_convert, TRUE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static GimpScanConvert *
|
|
|
|
gimp_drawable_render_boundary (GimpDrawable *drawable,
|
|
|
|
const BoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
2003-09-30 23:16:51 +08:00
|
|
|
BoundSeg *stroke_segs;
|
|
|
|
gint n_stroke_segs;
|
|
|
|
GimpVector2 *points;
|
|
|
|
gint n_points;
|
|
|
|
gint seg;
|
2003-10-01 02:06:19 +08:00
|
|
|
gint i;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2003-11-22 21:38:11 +08:00
|
|
|
if (n_bound_segs == 0)
|
2008-10-25 21:12:48 +08:00
|
|
|
return NULL;
|
2003-09-30 10:44:17 +08:00
|
|
|
|
2005-08-20 23:46:37 +08:00
|
|
|
stroke_segs = boundary_sort (bound_segs, n_bound_segs, &n_stroke_segs);
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
if (n_stroke_segs == 0)
|
2008-10-25 21:12:48 +08:00
|
|
|
return NULL;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
scan_convert = gimp_scan_convert_new ();
|
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
points = g_new0 (GimpVector2, n_bound_segs + 4);
|
|
|
|
|
|
|
|
seg = 0;
|
|
|
|
n_points = 0;
|
|
|
|
|
2003-12-21 23:57:43 +08:00
|
|
|
points[n_points].x = (gdouble) (stroke_segs[0].x1 + offset_x);
|
2003-11-13 11:27:21 +08:00
|
|
|
points[n_points].y = (gdouble) (stroke_segs[0].y1 + offset_y);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
|
|
|
n_points++;
|
|
|
|
|
|
|
|
for (i = 0; i < n_stroke_segs; i++)
|
|
|
|
{
|
|
|
|
while (stroke_segs[seg].x1 != -1 ||
|
|
|
|
stroke_segs[seg].x2 != -1 ||
|
|
|
|
stroke_segs[seg].y1 != -1 ||
|
|
|
|
stroke_segs[seg].y2 != -1)
|
|
|
|
{
|
2003-11-13 11:27:21 +08:00
|
|
|
points[n_points].x = (gdouble) (stroke_segs[seg].x1 + offset_x);
|
|
|
|
points[n_points].y = (gdouble) (stroke_segs[seg].y1 + offset_y);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
|
|
|
n_points++;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the stroke points up */
|
|
|
|
points[n_points] = points[0];
|
|
|
|
|
|
|
|
n_points++;
|
|
|
|
|
|
|
|
gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE);
|
|
|
|
|
|
|
|
n_points = 0;
|
|
|
|
seg++;
|
|
|
|
|
2003-11-13 11:27:21 +08:00
|
|
|
points[n_points].x = (gdouble) (stroke_segs[seg].x1 + offset_x);
|
|
|
|
points[n_points].y = (gdouble) (stroke_segs[seg].y1 + offset_y);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
|
|
|
n_points++;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (points);
|
|
|
|
g_free (stroke_segs);
|
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
return scan_convert;
|
2003-09-30 10:44:17 +08:00
|
|
|
}
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
static GimpScanConvert *
|
|
|
|
gimp_drawable_render_vectors (GimpDrawable *drawable,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean do_stroke)
|
2003-09-21 03:58:26 +08:00
|
|
|
{
|
2003-09-27 23:29:21 +08:00
|
|
|
GimpScanConvert *scan_convert;
|
2003-10-01 02:06:19 +08:00
|
|
|
GimpStroke *stroke;
|
|
|
|
gint num_coords = 0;
|
2003-09-27 23:29:21 +08:00
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
scan_convert = gimp_scan_convert_new ();
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-09-21 03:58:26 +08:00
|
|
|
/* For each Stroke in the vector, interpolate it, and add it to the
|
2003-09-28 04:04:07 +08:00
|
|
|
* ScanConvert
|
|
|
|
*/
|
2003-09-21 03:58:26 +08:00
|
|
|
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
|
|
|
stroke;
|
|
|
|
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
|
|
|
|
{
|
2007-10-12 21:14:43 +08:00
|
|
|
GArray *coords;
|
|
|
|
gboolean closed;
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
/* Get the interpolated version of this stroke, and add it to our
|
2003-09-28 04:04:07 +08:00
|
|
|
* scanconvert.
|
|
|
|
*/
|
2003-09-28 12:00:50 +08:00
|
|
|
coords = gimp_stroke_interpolate (stroke, 0.2, &closed);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
if (coords && coords->len)
|
|
|
|
{
|
2007-10-12 21:14:43 +08:00
|
|
|
GimpVector2 *points = g_new0 (GimpVector2, coords->len);
|
|
|
|
gint i;
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-09-21 03:58:26 +08:00
|
|
|
for (i = 0; i < coords->len; i++)
|
|
|
|
{
|
|
|
|
points[i].x = g_array_index (coords, GimpCoords, i).x;
|
|
|
|
points[i].y = g_array_index (coords, GimpCoords, i).y;
|
|
|
|
num_coords++;
|
|
|
|
}
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-09-21 03:58:26 +08:00
|
|
|
gimp_scan_convert_add_polyline (scan_convert, coords->len,
|
2008-10-25 21:12:48 +08:00
|
|
|
points, closed || !do_stroke);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
g_free (points);
|
|
|
|
}
|
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
if (coords)
|
|
|
|
g_array_free (coords, TRUE);
|
2003-09-21 03:58:26 +08:00
|
|
|
}
|
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
if (num_coords > 0)
|
2008-10-25 21:12:48 +08:00
|
|
|
return scan_convert;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
static void
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpScanConvert *scan_convert,
|
|
|
|
gboolean do_stroke,
|
|
|
|
gboolean push_undo)
|
2003-09-30 23:16:51 +08:00
|
|
|
{
|
2004-10-20 06:52:04 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
2008-10-25 21:12:48 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
2003-09-30 23:16:51 +08:00
|
|
|
TileManager *base;
|
|
|
|
TileManager *mask;
|
2003-10-07 01:13:57 +08:00
|
|
|
gint x, y, w, h;
|
|
|
|
gint bytes;
|
2007-12-27 01:33:41 +08:00
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
2003-09-30 23:16:51 +08:00
|
|
|
guchar bg[1] = { 0, };
|
2007-12-27 01:33:41 +08:00
|
|
|
PixelRegion maskPR;
|
|
|
|
PixelRegion basePR;
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2004-10-21 06:06:00 +08:00
|
|
|
/* must call gimp_channel_is_empty() instead of relying on
|
|
|
|
* gimp_drawable_mask_intersect() because the selection pretends to
|
|
|
|
* be empty while it is being stroked, to prevent masking itself.
|
|
|
|
*/
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_channel_is_empty (gimp_image_get_mask (image)))
|
2004-10-21 06:06:00 +08:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2008-11-03 08:09:01 +08:00
|
|
|
w = gimp_item_get_width (GIMP_ITEM (drawable));
|
|
|
|
h = gimp_item_get_height (GIMP_ITEM (drawable));
|
2004-10-21 06:06:00 +08:00
|
|
|
}
|
|
|
|
else if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
if (do_stroke)
|
|
|
|
{
|
|
|
|
GimpStrokeOptions *stroke_options = GIMP_STROKE_OPTIONS (options);
|
|
|
|
gdouble width = stroke_options->width;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
if (stroke_options->unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
2003-09-30 07:45:06 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
2003-09-30 07:45:06 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_scan_convert_set_pixel_ratio (scan_convert, yres / xres);
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
width *= (image->yresolution /
|
|
|
|
_gimp_unit_get_factor (image->gimp, stroke_options->unit));
|
|
|
|
}
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_scan_convert_stroke (scan_convert, width,
|
|
|
|
stroke_options->join_style,
|
|
|
|
stroke_options->cap_style,
|
|
|
|
stroke_options->miter_limit,
|
|
|
|
stroke_options->dash_offset,
|
|
|
|
stroke_options->dash_info);
|
2003-09-30 07:45:06 +08:00
|
|
|
}
|
|
|
|
|
2003-09-21 08:58:04 +08:00
|
|
|
/* fill a 1-bpp Tilemanager with black, this will describe the shape
|
2003-09-28 04:04:07 +08:00
|
|
|
* of the stroke.
|
|
|
|
*/
|
2003-09-21 08:58:04 +08:00
|
|
|
mask = tile_manager_new (w, h, 1);
|
|
|
|
pixel_region_init (&maskPR, mask, 0, 0, w, h, TRUE);
|
|
|
|
color_region (&maskPR, bg);
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-09-21 08:58:04 +08:00
|
|
|
/* render the stroke into it */
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
2003-10-07 00:43:05 +08:00
|
|
|
gimp_scan_convert_render (scan_convert, mask,
|
2003-10-07 01:13:57 +08:00
|
|
|
x + off_x, y + off_y,
|
2008-10-24 05:18:39 +08:00
|
|
|
GIMP_FILL_OPTIONS (options)->antialias);
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
bytes = gimp_drawable_bytes_with_alpha (drawable);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2003-09-28 04:04:07 +08:00
|
|
|
base = tile_manager_new (w, h, bytes);
|
|
|
|
pixel_region_init (&basePR, base, 0, 0, w, h, TRUE);
|
|
|
|
pixel_region_init (&maskPR, mask, 0, 0, w, h, FALSE);
|
2003-09-23 07:19:22 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
switch (options->style)
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2008-10-24 05:30:28 +08:00
|
|
|
case GIMP_FILL_STYLE_SOLID:
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2003-10-07 01:13:57 +08:00
|
|
|
guchar tmp_col[MAX_CHANNELS] = { 0, };
|
|
|
|
guchar col[MAX_CHANNELS] = { 0, };
|
2003-09-27 23:29:21 +08:00
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
gimp_rgb_get_uchar (&context->foreground,
|
2008-10-19 21:47:09 +08:00
|
|
|
&tmp_col[RED],
|
|
|
|
&tmp_col[GREEN],
|
|
|
|
&tmp_col[BLUE]);
|
2003-09-27 23:29:21 +08:00
|
|
|
|
2006-10-26 06:14:36 +08:00
|
|
|
gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
|
|
|
|
GIMP_RGB, tmp_col);
|
2003-09-28 04:42:31 +08:00
|
|
|
col[bytes - 1] = OPAQUE_OPACITY;
|
2003-09-28 04:04:07 +08:00
|
|
|
|
2003-09-28 04:42:31 +08:00
|
|
|
color_region_mask (&basePR, &maskPR, col);
|
2003-09-28 04:04:07 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-10-24 05:30:28 +08:00
|
|
|
case GIMP_FILL_STYLE_PATTERN:
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
|
|
|
GimpPattern *pattern;
|
|
|
|
TempBuf *pat_buf;
|
|
|
|
gboolean new_buf;
|
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
pattern = gimp_context_get_pattern (context);
|
2006-10-26 06:14:36 +08:00
|
|
|
pat_buf = gimp_image_transform_temp_buf (image,
|
|
|
|
gimp_drawable_type (drawable),
|
2003-09-28 04:04:07 +08:00
|
|
|
pattern->mask, &new_buf);
|
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
pattern_region (&basePR, &maskPR, pat_buf, x, y);
|
2003-09-28 04:04:07 +08:00
|
|
|
|
|
|
|
if (new_buf)
|
|
|
|
temp_buf_free (pat_buf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2003-09-21 08:58:04 +08:00
|
|
|
/* Apply to drawable */
|
|
|
|
pixel_region_init (&basePR, base, 0, 0, w, h, FALSE);
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_drawable_apply_region (drawable, &basePR,
|
2008-10-25 19:59:03 +08:00
|
|
|
push_undo, _("Render Stroke"),
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_context_get_paint_mode (context),
|
2008-11-09 03:52:18 +08:00
|
|
|
NULL, NULL, x, y);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
tile_manager_unref (mask);
|
|
|
|
tile_manager_unref (base);
|
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
gimp_drawable_update (drawable, x, y, w, h);
|
2003-09-21 03:58:26 +08:00
|
|
|
}
|