RSS/Atom feed Twitter
Site is read-only, email is disabled

Create and add new layers in a GimpPreview widget

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 1 message available
Toggle history

Please log in to manage your subscriptions.

Create and add new layers in a GimpPreview widget Alessandro Francesconi 30 Jun 20:51
Alessandro Francesconi
2013-06-30 20:51:53 UTC (almost 12 years ago)

Create and add new layers in a GimpPreview widget

Hello,

my plugin performs a series of image algorithms and provides a GimpDrawablePreview widget. One of those operations works by adding a new layer to the image, I have no problems when apply it to the "real" image... but things changes if I try to show a preview of it.

Basically, the algorithm is the following:

/* ----------------- */

// double the region int new_layer = gimp_layer_new_from_drawable (drawable->drawable_id, gimp_drawable_get_image (drawable->drawable_id));

// pixel operation on the original layer/drawable....

// apply changes if (preview) {
gimp_drawable_preview_draw_region (GIMP_DRAWABLE_PREVIEW (preview), dst_rgn); }
else {
gimp_drawable_flush (drawable); gimp_drawable_merge_shadow (drawable->drawable_id, undo); gimp_drawable_update (drawable->drawable_id, dst_rgn->x, dst_rgn->y, dst_rgn->w, dst_rgn->h); }

// set new layer's mode
gimp_layer_set_mode (drawable->drawable_id, GIMP_DIFFERENCE_MODE);

// add the layer and merge gimp_image_add_layer (gimp_drawable_get_image (drawable->drawable_id), new_layer, 1); int new_drawable = gimp_image_merge_visible_layers(gimp_drawable_get_image (drawable->drawable_id), GIMP_CLIP_TO_IMAGE);

/* ----------------- */

Problem is at the last line, when executed it says "tried reading from drawable 30 which was removed from the image (killing)"... but only in preview mode. I guess that drawables in a preview widget must be managed in a different way... but how? Is there an example of plugin that uses layers plus a preview window?

Thanks!