Commit 71785ac8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

canonicalize hardcoded procedure names.

2005-08-06  Sven Neumann  <sven@gimp.org>

	* app/batch.c: canonicalize hardcoded procedure names.

	* app/base/siox.[ch]
	* app/core/gimpdrawable-foreground-extract.[ch]
	* app/tools/gimpforegroundselecttool.c: restrict the working area
	to the double of the bounding box of the initial selection.
parent e918085d
2005-08-06 Sven Neumann <sven@gimp.org>
* app/batch.c: canonicalize hardcoded procedure names.
* app/base/siox.[ch]
* app/core/gimpdrawable-foreground-extract.[ch]
* app/tools/gimpforegroundselecttool.c: restrict the working area
to the double of the bounding box of the initial selection.
2005-08-05 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
......
......@@ -44,7 +44,7 @@
#include "paint-funcs/paint-funcs.h"
#include "core/gimp-utils.h" /* FIXME */
#include "core/gimp-utils.h" /* FIXME (gimp_rectangle_intersect) */
#include "cpercep.h"
#include "pixel-region.h"
......@@ -781,6 +781,10 @@ siox_progress_update (SioxProgressFunc progress_callback,
* @mask: a mask indicating sure foreground (255), sure background (0)
* and undecided regions ([1..254]).
* @x: horizontal offset into the mask
* @y: vertical offset into the mask
* @width: width of working area on mask
* @height: height of working area on mask
* @limits: a three dimensional float array specifing the accuracy,
* a good value is: { 0.66, 1.25, 2.5 }
* @smoothness: boundary smoothness (a good value is 3)
......@@ -793,6 +797,10 @@ siox_foreground_extract (TileManager *pixels,
gint offset_x,
gint offset_y,
TileManager *mask,
gint x,
gint y,
gint width,
gint height,
const gfloat limits[SIOX_DIMS],
gint smoothness,
SioxProgressFunc progress_callback,
......@@ -802,8 +810,6 @@ siox_foreground_extract (TileManager *pixels,
PixelRegion mapPR;
gpointer pr;
gboolean intersect;
gint x, y;
gint width, height;
gint bpp;
gint row, col;
const gfloat clustersize = get_clustersize (limits);
......@@ -818,16 +824,16 @@ siox_foreground_extract (TileManager *pixels,
g_return_if_fail (pixels != NULL);
g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1);
g_return_if_fail (x >= 0);
g_return_if_fail (y >= 0);
g_return_if_fail (x + width <= tile_manager_width (mask));
g_return_if_fail (y + height <= tile_manager_height (mask));
g_return_if_fail (progress_data == NULL || progress_callback != NULL);
cpercep_init ();
intersect = gimp_rectangle_intersect (offset_x, offset_y,
tile_manager_width (pixels),
tile_manager_height (pixels),
0, 0,
tile_manager_width (mask),
tile_manager_height (mask),
x, y, width, height,
&x, &y, &width, &height);
/* FIXME:
......@@ -837,6 +843,8 @@ siox_foreground_extract (TileManager *pixels,
if (! intersect)
return;
cpercep_init ();
siox_progress_update (progress_callback, progress_data, 0.0);
/* count given foreground and background pixels */
......@@ -874,7 +882,7 @@ siox_foreground_extract (TileManager *pixels,
bpp = tile_manager_bpp (pixels);
/* create inputs for colorsignatures */
/* create inputs for color signatures */
pixel_region_init (&srcPR, pixels,
x - offset_x, y - offset_y, width, height, FALSE);
pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);
......
......@@ -50,6 +50,10 @@ void siox_foreground_extract (TileManager *pixels,
gint offset_x,
gint offset_y,
TileManager *map,
gint x,
gint y,
gint width,
gint height,
const gfloat limits[SIOX_DIMS],
gint smoothness,
SioxProgressFunc progress_callback,
......
......@@ -36,7 +36,7 @@
#include "gimp-intl.h"
#define BATCH_DEFAULT_EVAL_PROC "plug_in_script_fu_eval"
#define BATCH_DEFAULT_EVAL_PROC "plug-in-script-fu-eval"
static gboolean batch_exit_after_callback (Gimp *gimp,
......@@ -72,10 +72,10 @@ batch_run (Gimp *gimp,
/* script-fu text console, hardcoded for backward compatibility */
if (strcmp (batch_interpreter, "plug_in_script_fu_eval") == 0 &&
if (strcmp (batch_interpreter, "plug-in-script-fu-eval") == 0 &&
strcmp (batch_commands[0], "-") == 0)
{
const gchar *proc_name = "plug_in_script_fu_text_console";
const gchar *proc_name = "plug-in-script-fu-text-console";
ProcRecord *proc = procedural_db_lookup (gimp, proc_name);
if (proc)
......
......@@ -43,10 +43,30 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
GimpProgress *progress)
{
g_return_if_fail (GIMP_IS_DRAWABLE (mask));
gimp_drawable_foreground_extract_rect (drawable, mode, mask,
0, 0,
gimp_item_width (GIMP_ITEM (mask)),
gimp_item_height (GIMP_ITEM (mask)),
progress);
}
void
gimp_drawable_foreground_extract_rect (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
gint x,
gint y,
gint width,
gint height,
GimpProgress *progress)
{
GimpImage *gimage;
const guchar *colormap = NULL;
gint x, y;
const guchar *colormap = NULL;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
......@@ -61,7 +81,7 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
colormap = gimp_image_get_colormap (gimage);
gimp_item_offsets (GIMP_ITEM (drawable), &x, &y);
gimp_item_offsets (GIMP_ITEM (drawable), &offset_x, &offset_y);
if (progress)
gimp_progress_start (progress, _("Foreground Extraction..."), FALSE);
......@@ -70,10 +90,11 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
{
case GIMP_FOREGROUND_EXTRACT_SIOX:
{
const gfloat limits[SIOX_DIMS] = { 0.66, 1.25, 2.5 };
const gfloat limits[SIOX_DIMS] = { 0.66, 1.25, 2.5 };
siox_foreground_extract (gimp_drawable_data (drawable), colormap, x, y,
gimp_drawable_data (mask),
siox_foreground_extract (gimp_drawable_data (drawable), colormap,
offset_x, offset_y,
gimp_drawable_data (mask), x, y, width, height,
limits, 3,
(SioxProgressFunc) gimp_progress_set_value,
progress);
......
......@@ -20,10 +20,17 @@
#define __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__
void gimp_drawable_foreground_extract (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
GimpProgress *progress);
void gimp_drawable_foreground_extract (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
GimpProgress *progress);
void gimp_drawable_foreground_extract_rect (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
gint x,
gint y,
gint width,
gint height,
GimpProgress *progress);
#endif /* __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__ */
......@@ -489,6 +489,9 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
GimpScanConvert *scan_convert;
GimpChannel *mask;
GList *list;
gint x, y;
gint x2, y2;
gint width, height;
if (! drawable)
return;
......@@ -509,13 +512,25 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
0, 0, 127);
gimp_scan_convert_free (scan_convert);
gimp_channel_bounds (mask, &x, &y, &x2, &y2);
width = x2 - x;
height = y2 - y;
/* restrict working area to double the size of the bounding box */
x = MAX (0, x - width / 2);
y = MAX (0, y - height / 2);
width = MIN (width * 2, gimp_item_width (GIMP_ITEM (mask)) - x);
height = MIN (height * 2, gimp_item_height (GIMP_ITEM (mask)) - y);
/* apply foreground and background markers */
for (list = fg_select->strokes; list; list = list->next)
gimp_foreground_select_tool_stroke (mask, list->data);
gimp_drawable_foreground_extract (drawable,
GIMP_FOREGROUND_EXTRACT_SIOX,
GIMP_DRAWABLE (mask),
GIMP_PROGRESS (gdisp));
gimp_drawable_foreground_extract_rect (drawable,
GIMP_FOREGROUND_EXTRACT_SIOX,
GIMP_DRAWABLE (mask),
x, y, width, height,
GIMP_PROGRESS (gdisp));
gimp_foreground_select_tool_set_mask (GIMP_FOREGROUND_SELECT_TOOL (free_sel),
gdisp, mask);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment