[Gimp-developer] gimp drawable question



Hi,

I am working on a plugin and need a help with understanding how drawables works.

I would first describe what the plugin should do:
1. You open an image (lets presume the image is single layered)
2. User launches a plugin, it reads content of image and keep it in memory
3. User paints something to the image and hits a button on the plugin window (plugin stays alive all the time)
4. The plugin will read content from image, do some calculations and changes the image back.

And steps 3 are 4 are repeated many times.

First issue I run into is that when I want to paint (with paintbrush tool f.e.) to the image again,  what I had painted in previous iteration is lost - it dissapears... This is my question for now, how to avoid this behaviour...

If I shoud provide some code, my "core" function that is called everytime the button is hit contains following....

gimp_pixel_rgn_init (&rgn_in, source,x1, y1, maindata.width, maindata.height,FALSE, FALSE);
gimp_pixel_rgn_init (&rgn_out, source, x1, y1, maindata.width, maindata.height, FALSE,TRUE);
                      
gimp_pixel_rgn_get_rect (&rgn_in,rect_in,x1, y1,maindata.width,maindata.height);
#here plugin calculates rect_out
gimp_pixel_rgn_set_rect (&rgn_out, rect_out,x1, y1,maindata.width,maindata.height);

gimp_drawable_flush (source);
gimp_drawable_merge_shadow (source->drawable_id, FALSE);
gimp_drawable_update (source->drawable_id,x1,y1,maindata.width,maindata.height);
   
I had read your Gimp reference manual but to no avail :)

Thanks !!

Tibor


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]