fixed handling of the empty selection mask (bug #489410).

2007-10-23  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/fp.c: fixed handling of the empty selection
	mask (bug #489410).


svn path=/trunk/; revision=23926
This commit is contained in:
Sven Neumann 2007-10-23 19:15:22 +00:00 committed by Sven Neumann
parent 1d58e18dc5
commit 1ed2d6528b
2 changed files with 50 additions and 24 deletions

View File

@ -1,3 +1,8 @@
2007-10-23 Sven Neumann <sven@gimp.org>
* plug-ins/common/fp.c: fixed handling of the empty selection
mask (bug #489410).
2007-10-23 Sven Neumann <sven@gimp.org>
* plug-ins/common/fp.c: made preview windows transient to the

View File

@ -24,6 +24,7 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
@ -282,8 +283,8 @@ static FPValues fpvals =
{ FALSE, FALSE, FALSE } /* touched */
};
static GimpDrawable *drawable;
static GimpDrawable *mask;
static GimpDrawable *drawable = NULL;
static GimpDrawable *mask = NULL;
static void query (void);
static void run (const gchar *name,
@ -353,6 +354,10 @@ run (const gchar *name,
fp_init_filter_packs();
drawable = gimp_drawable_get (param[2].data.d_drawable);
if (gimp_selection_is_empty (param[1].data.d_image))
mask = NULL;
else
mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
switch (run_mode)
@ -403,13 +408,17 @@ run (const gchar *name,
gimp_displays_flush ();
}
else status = GIMP_PDB_EXECUTION_ERROR;
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
values[0].data.d_status = status;
if (status == GIMP_PDB_SUCCESS)
gimp_drawable_detach (drawable);
if (mask)
gimp_drawable_detach (mask);
values[0].data.d_status = status;
}
static void
@ -1187,7 +1196,7 @@ fp_dialog (void)
fpvals.preview_size,
fpvals.selection_only);
gimp_ui_init (PLUG_IN_BINARY, TRUE);
gimp_ui_init (PLUG_IN_BINARY, FALSE);
dlg = gimp_dialog_new (_("Filter Pack Simulation"), PLUG_IN_BINARY,
NULL, 0,
@ -1654,17 +1663,27 @@ fp_reduce_image (GimpDrawable *drawable,
tempHSV = g_new (gdouble, RW * RH * bytes);
tempmask = g_new (guchar, RW * RH);
gimp_pixel_rgn_init (&srcPR, drawable, x, y, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&srcMask, mask, x, y, width, height, FALSE, FALSE);
src_row = g_new (guchar, width * bytes);
src_mask_row = g_new (guchar, width * bytes);
src_mask_row = g_new (guchar, width);
gimp_pixel_rgn_init (&srcPR, drawable, x, y, width, height, FALSE, FALSE);
if (mask)
{
gimp_pixel_rgn_init (&srcMask, mask, x, y, width, height, FALSE, FALSE);
}
else
{
memset (src_mask_row, 255, width);
}
for (i = 0; i < RH; i++)
{
whichrow = (gdouble) i * (gdouble) height / (gdouble) RH;
gimp_pixel_rgn_get_row (&srcPR, src_row, x, y + whichrow, width);
if (mask)
gimp_pixel_rgn_get_row (&srcMask, src_mask_row, x, y + whichrow, width);
for (j = 0; j < RW; j++)
@ -1689,10 +1708,12 @@ fp_reduce_image (GimpDrawable *drawable,
tempHSV[i * RW * bytes + j * bytes + 2] = hsv.v;
if (bytes == 4)
{
tempRGB[i * RW * bytes + j * bytes + 3] =
src_row[whichcol * bytes + 3];
}
}
}
g_free (src_row);
g_free (src_mask_row);