You are here

c++ plugin problem

hi,
i'm going crazy. i'm new to programming with gimp. gimp's reference hasn't examples .... please have a look at this. it was the blur example from gimp and i only want to test the by_color_select function... but i'm too stupid for it. it compiles with no errors or warnings. i'm on a 64bit linux with gcc 4.3.2


#include

static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void blur (GimpDrawable *drawable);

GimpPlugInInfo PLUG_IN_INFO =
{
NULL,
NULL,
query,
run
};

MAIN()

static void
query (void)
{
static GimpParamDef args[] =
{
{
GIMP_PDB_INT32,
"run-mode",
"Run mode"
},
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Input drawable"
}
};

gimp_install_procedure (
"plug-in-myblur1",
"My blur 1 (slow)",
"Blurs the image",
"David Neary",
"Copyright David Neary",
"2004",
"_My blur 1 (slow)",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);

gimp_plugin_menu_register ("plug-in-myblur1",
"/test/neu");
}

static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunMode run_mode;
GimpDrawable *drawable;

/* Setting mandatory output values */
*nreturn_vals = 1;
*return_vals = values;

values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;

/* Getting run_mode - we won't display a dialog if
* we are in NONINTERACTIVE mode
*/
run_mode = param[0].data.d_int32;

/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);

gimp_progress_init ("My Blur...");
blur (drawable);
gimp_displays_flush ();
gimp_drawable_detach (drawable);
}

static void
blur (GimpDrawable *drawable)
{
GimpRGB *color;
gimp_rgb_set(color,0,1.0,0);
gimp_by_color_select(drawable->drawable_id,color,1,GIMP_CHANNEL_OP_REPLACE,0,0,0,0);
gimp_edit_fill(drawable->drawable_id,GIMP_FOREGROUND_FILL);

gimp_drawable_flush(drawable);
}

what's wrong i get a segmentation fault
....
thanks and regards

Hi! I don't know what's wrong, but it's more easy to use debugger such like gdb, cgdb, etc... than staring source code. Did you read this? http://developer.gimp.org/debug-plug-ins.txt

thx for the tip. i didn't know that, but it's to late. i rewrote it in python, it's much slower but it works...
Subscribe to Comments for "c++ plugin problem"