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

preview update problems

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.

7 of 7 messages available
Toggle history

Please log in to manage your subscriptions.

preview update problems David Hodson 08 Jan 05:14
  preview update problems Sven Neumann 08 Jan 08:19
   preview update problems David Hodson 08 Jan 09:07
    preview update problems Sven Neumann 09 Jan 00:02
     preview update problems David Hodson 09 Jan 01:44
      preview update problems Sven Neumann 09 Jan 08:41
       preview update problems David Hodson 09 Jan 11:21
David Hodson
2007-01-08 05:14:52 UTC (over 17 years ago)

preview update problems

I'm having problems adding a preview (gimp_drawable_preview_new) to an existing plugin. Some experimentation with the sample code shows that using gimp_pixel_rgn_get_row() and gimp_pixel_rgn_set_row() to iterate through the image region, the preview updates correctly, but replacing them with gimp_pixel_rgns_register() and gimp_pixel_rgns_process() stops the preview updating. Why is this, and how do I cause a preview update?

Sven Neumann
2007-01-08 08:19:54 UTC (over 17 years ago)

preview update problems

Hi,

On Mon, 2007-01-08 at 15:14 +1100, David Hodson wrote:

I'm having problems adding a preview (gimp_drawable_preview_new) to an existing plugin. Some experimentation with the sample code shows that using gimp_pixel_rgn_get_row() and gimp_pixel_rgn_set_row() to iterate through the image region, the preview updates correctly, but replacing them with gimp_pixel_rgns_register() and gimp_pixel_rgns_process() stops the preview updating. Why is this, and how do I cause a preview update?

Have you looked at the code of the many plug-ins that use a preview already? The idea of a preview is to preview the effect. So you aren't going to manipulate the pixel regions at all. Instead you draw on the preview.

If you have specific question, it's probably best to make up a small test case and show us the code together with your question.

Sven

David Hodson
2007-01-08 09:07:00 UTC (over 17 years ago)

preview update problems

Sven Neumann wrote:

Have you looked at the code of the many plug-ins that use a preview already? The idea of a preview is to preview the effect. So you aren't going to manipulate the pixel regions at all. Instead you draw on the preview.

I'm looking at Dave Neary's sample code on the developer.gimp.org website, which uses two pixel regions, calling gimp_pixel_rgn_get_row() on one and gimp_pixel_rgn_set_row() on the other, and calls gimp_drawable_preview_draw_region() to update the preview. If I use gimp_pixel_rgns_process() to access the regions instead, the preview is not updated with the new data.

If you have specific question, it's probably best to make up a small test case and show us the code together with your question.

Replace the processing loops in Dave's blur() function:

for (ii = -bvals.radius; ii < rgn_in.h; ++i) { guchar* s = src;
guchar* d = dst;
for (ii = 0; ii < rgn_in.w; ++ii) { d[0] = 255 - s[0];
s += rgn_in.bpp;
d += rgn_out.bpp;
}
src += rgn_in.rowstride;
dst += rgn_out.rowstride;
}
}

Sven Neumann
2007-01-09 00:02:41 UTC (over 17 years ago)

preview update problems

Hi,

The code snippet you have posted doesn't include the part where you initialize the pixel regions. It would help if you could post a complete test case that we can compile and run.

Sven

David Hodson
2007-01-09 01:44:09 UTC (over 17 years ago)

preview update problems

Sven Neumann wrote:

The code snippet you have posted doesn't include the part where you initialize the pixel regions. It would help if you could post a complete test case that we can compile and run.

OK, I've put it at http://members.ozemail.com.au/~hodsond/myblur5.c

It's basically Dave Neary's code with his blur code replaced by something much simpler. At the top of the file, #define WORKING_VERSION as 1 to get his old code, 0 to get mine. (Obviously, search for WORKING_VERSION to see where the difference is.)

Sven Neumann
2007-01-09 08:41:50 UTC (over 17 years ago)

preview update problems

Hi,

On Tue, 2007-01-09 at 11:44 +1100, David Hodson wrote:

The code snippet you have posted doesn't include the part where you initialize the pixel regions. It would help if you could post a complete test case that we can compile and run.

OK, I've put it at http://members.ozemail.com.au/~hodsond/myblur5.c

You need to move the call to gimp_drawable_preview_draw_region() into the pixel region processing loop. This is because gimp_pixel_rgns_process() modifies the pixel regions it works on. The processed data is also already sent to the core when you are done with processing. You can't update the preview with that data at this point.

If you are using gimp_pixel_rgns_process() you should also remove the call to gimp_tile_cache_ntiles(). It isn't needed because the data is processed tile-by-tile.

Sven

David Hodson
2007-01-09 11:21:38 UTC (over 17 years ago)

preview update problems

Sven Neumann wrote:

You need to move the call to gimp_drawable_preview_draw_region() into the pixel region processing loop. This is because gimp_pixel_rgns_process() modifies the pixel regions it works on. The processed data is also already sent to the core when you are done with processing. You can't update the preview with that data at this point.

That makes sense. I guessed something like that was going on, but it's not obvious exactly where.

If you are using gimp_pixel_rgns_process() you should also remove the call to gimp_tile_cache_ntiles(). It isn't needed because the data is processed tile-by-tile.

It's OK, I don't have that in my plugin, it's just a remnant from the sample code.

Thanks for the help!