Re: [Gimp-developer] preview update problems

2007-01-09 Thread David Hodson
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!

-- 
David Hodson  --  this night wounds time
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] preview update problems

2007-01-08 Thread Sven Neumann
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


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] preview update problems

2007-01-08 Thread David Hodson
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.)

-- 
David Hodson  --  this night wounds time
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] preview update problems

2007-01-08 Thread Sven Neumann
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


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] preview update problems

2007-01-07 Thread Sven Neumann
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


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] preview update problems

2007-01-07 Thread David Hodson
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 = bvals.radius; ii++)
   {
[...]
   gimp_progress_update ((gdouble) i / (gdouble) height);
   }

  with:

   guchar* pr = gimp_pixel_rgns_register(2, rgn_in, rgn_out);
   for ( ; pr != 0; pr = gimp_pixel_rgns_process(pr)) {
 guchar* src = rgn_in.data;
 guchar* dst = rgn_out.data;
 for (i = 0; i  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;
 }
   }


-- 
David Hodson  --  this night wounds time
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer