make Convolve work with very thin brushes, then convolving only in one

2008-05-27  Sven Neumann  <sven@gimp.org>

	* app/paint/gimpconvolve.c: make Convolve work with very thin
	brushes, then convolving only in one direction (bug #533791).

svn path=/trunk/; revision=25823
This commit is contained in:
Sven Neumann 2008-05-27 08:19:30 +00:00 committed by Sven Neumann
parent ae67f09ddd
commit 4baadd8671
2 changed files with 24 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2008-05-27 Sven Neumann <sven@gimp.org>
* app/paint/gimpconvolve.c: make Convolve work with very thin
brushes, then convolving only in one direction (bug #533791).
2008-05-26 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am

View File

@ -57,6 +57,8 @@ static void gimp_convolve_motion (GimpPaintCore *paint_core,
static void gimp_convolve_calculate_matrix (GimpConvolve *convolve,
GimpConvolveType type,
gint radius_x,
gint radius_y,
gdouble rate);
static gdouble gimp_convolve_sum_matrix (const gfloat *matrix);
@ -137,11 +139,6 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
if (gimp_drawable_is_indexed (drawable))
return;
/* If the brush is smaller than the convolution matrix, don't convolve */
if (brush_core->brush->mask->width < 3 ||
brush_core->brush->mask->height < 3)
return;
opacity = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
if (opacity == 0.0)
@ -157,7 +154,10 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
&paint_core->cur_coords,
paint_core->use_pressure);
gimp_convolve_calculate_matrix (convolve, options->type, rate);
gimp_convolve_calculate_matrix (convolve, options->type,
brush_core->brush->mask->width / 2,
brush_core->brush->mask->height / 2,
rate);
/* configure the source pixel region */
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
@ -218,10 +218,17 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
static void
gimp_convolve_calculate_matrix (GimpConvolve *convolve,
GimpConvolveType type,
gint radius_x,
gint radius_y,
gdouble rate)
{
/* find percent of tool pressure */
gdouble percent = MIN (rate / 100.0, 1.0);
const gdouble percent = MIN (rate / 100.0, 1.0);
convolve->matrix[0] = (radius_x && radius_y) ? 1.0 : 0.0;
convolve->matrix[1] = (radius_y) ? 1.0 : 0.0;
convolve->matrix[2] = (radius_x && radius_y) ? 1.0 : 0.0;
convolve->matrix[3] = (radius_x) ? 1.0 : 0.0;
/* get the appropriate convolution matrix and size and divisor */
switch (type)
@ -238,6 +245,11 @@ gimp_convolve_calculate_matrix (GimpConvolve *convolve,
break;
}
convolve->matrix[5] = (radius_x) ? 1.0 : 0.0;
convolve->matrix[6] = (radius_x && radius_y) ? 1.0 : 0.0;
convolve->matrix[7] = (radius_y) ? 1.0 : 0.0;
convolve->matrix[8] = (radius_x && radius_y) ? 1.0 : 0.0;
convolve->matrix_divisor = gimp_convolve_sum_matrix (convolve->matrix);
}