> You can't show a drawable by itself, it needs to be in an image. Also, an > image can't show itself, you must create a display for that. You are also > using the API in weird ways, for example, objects such as layers and images > are represented by integers in the plug-in context. > > You are also saying that the plug-in takes the active image and drawable as > parameter, but since you are creating a new image, you are not interested in > those values (I assume) so there is no point in specifying these as > arguments to the hello-world procedure. This is my first attempt to write a GIMP plugin, as you probably have guessed by now =) > I have attached a rewritten version of main.c (called hello-world.c since > that is a name that doesn't conflict as much) that should do what you want. > You might also want to consider using a scripting language like Scheme or > Python for this. Wow. That's amazing. Thank you very much =) What I ultimately would like to end up with is being able to set pixels, the user makes changes to the image, and I read the pixels one by one again. So now I have tried to set a pixel like so /* Trying to set a pixel at x=5,y=5 with value 150 */ GimpDrawable* drawable; drawable = gimp_drawable_get (layer); /* Trying to set a pixel at x=5,y=5 with value 150 in 24 bit color */ gboolean s; s = gimp_drawable_set_pixel (drawable, 5, 5, 24, 150); But when I compile I get: hello-world.c:73: warning: passing argument 1 of ‘gimp_drawable_set_pixel’ makes integer from pointer without a cast /usr/include/gimp-2.0/libgimp/gimpdrawable_pdb.h:89: note: expected ‘gint32’ but argument is of type ‘struct GimpDrawable *’ The code is attached. I am bit lost how to solve this. Any help will be very appreciated =)
#include <libgimp/gimp.h> static void query (void) { static GimpParamDef args[] = { { GIMP_PDB_INT32, "run-mode", "Run mode" }, }; gimp_install_procedure ( "plug-in-hello", "Hello, world!", "Displays \"Hello, world!\" in a dialog", "David Neary", "Copyright David Neary", "2004", "_Hello world...", NULL, GIMP_PLUGIN, G_N_ELEMENTS (args), 0, args, NULL); gimp_plugin_menu_register ("plug-in-hello", "<Image>/Filters/Misc"); } 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; gint32 image; gint32 layer; gint32 display; /* 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; image = gimp_image_new (800, 600, GIMP_RGB); layer = gimp_layer_new (image, "foo", 800, 600, GIMP_RGBA_IMAGE, 100.0, GIMP_NORMAL_MODE); gimp_image_add_layer (image, layer, 0); /* Trying to set a pixel at x=5,y=5 with value 150 */ GimpDrawable* drawable; drawable = gimp_drawable_get (layer); /* Trying to set a pixel at x=5,y=5 with value 150 in 24 bit color */ gboolean s; s = gimp_drawable_set_pixel (drawable, 5, 5, 24, 150); display = gimp_display_new (image); if (run_mode != GIMP_RUN_NONINTERACTIVE) g_message("Hello, world!\n"); } GimpPlugInInfo PLUG_IN_INFO = { NULL, NULL, query, run }; MAIN()
_______________________________________________ Gimp-developer mailing list Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer