[Gimp-developer] Double tile iterators?

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

 



Hello all,
	I've just started writing my first gimp plugin, so I'm very new at
this.  Hope nobody minds my stupid questions ;-)

So what I'm trying to do is make a plugin that selects certain regions of
an image (the regions selected will depend on what's in the image).  I've
already managed to make it so that it can select a pre-defined
(i.e. defined in the source) area, but now I need to make that area depend
on the contents of the image.

I thought about using some kind of "double tile iterator" to do this, e.g:

  gimp_pixel_rgn_init (&image_rgn, image_drawable,
			x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
  gimp_pixel_rgn_init (&select_rgn, select_drawable,
			x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
  for (p1 = gimp_pixel_rgns_register (1, &image_rgn),
	 p2 = gimp_pixel_rgns_register (1, &select_rgn);
       (p1 != NULL) && (p2 != NULL);
       p1 = gimp_pixel_rgns_process (p1),
	 p2 = gimp_pixel_rgns_process (p2))
    {
	/* Interesting stuff goes in here!            */
	/* Set some of the pixels in select_drawable  */
	/* depending on the pixels in image_drawable. */
    }


but then it occurred to me that the tiles that get iterated over will not
necessarily be of the same size for the image_drawable and select_drawable
which would cause this loop to go horribly wrong!

Can anyone suggest what the Right Thing to do here is?  I know it's
possible to look at image_drawable on a pixel-by-pixel basis (rather
than tile-by-tile), but from what I've read this will make things *very*
slow and obviously I don't want that ;-)

Thanks for any help.
Best wishes,
		Bill.


[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux