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

PixelRegions?

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.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

PixelRegions? Michael Thaler 16 Jun 21:41
  PixelRegions? Frédéric 16 Jun 22:52
   PixelRegions? Nathan Summers 17 Jun 23:53
Michael Thaler
2006-06-16 21:41:40 UTC (almost 18 years ago)

PixelRegions?

Hello,

I am trying to understand the siox-tool code. While looking at the code, I discovered the following:

static inline void threshold_mask (TileManager *mask, gint x, gint y, gint width, gint height)
{
PixelRegion region;
gpointer pr;
gint row, col;

pixel_region_init (®ion, mask, x, y, width, height, TRUE);

for (pr = pixel_regions_register (1, ®ion); pr != NULL; pr = pixel_regions_process (pr)) {
Iterate over all pixels in the region and do something... }
}

Can someone explain to me why the code iterates over all pixels in a region and then over all regions and not just over all pixels in a layer? What are PixelRegions actually, what are they used for and why they are needed here? (I had a look at http://developer.gimp.org/api/2.0/app/app-pixel-region.html but this doesn't explain what they are for)

Thank you very much in advance, Michael

Frédéric
2006-06-16 22:52:09 UTC (almost 18 years ago)

PixelRegions?

On Friday 16 June 2006 21:41, Michael Thaler wrote:

Can someone explain to me why the code iterates over all pixels in a region and then over all regions and not just over all pixels in a layer? What are PixelRegions actually, what are they used for and why they are needed here? (I had a look at http://developer.gimp.org/api/2.0/app/app-pixel-region.html but this doesn't explain what they are for)

As far as I understand, a region can be what you want; it can cover a entire layer, or just a small part (like the preview for plug-ins. Have a look here:

http://developer.gimp.org/writing-a-plug-in/2/index.html

When you have initialized a region, you can access it pixel by pixel, row by row, or tile by tile, depending what you want to do (I guess each method has advantages, according to the filter you want to write).

Nathan Summers
2006-06-17 23:53:49 UTC (almost 18 years ago)

PixelRegions?

On 6/16/06, Frédéric wrote:

On Friday 16 June 2006 21:41, Michael Thaler wrote:

Can someone explain to me why the code iterates over all pixels in a region and then over all regions and not just over all pixels in a layer? What are PixelRegions actually, what are they used for and why they are needed here? (I had a look at http://developer.gimp.org/api/2.0/app/app-pixel-region.html but this doesn't explain what they are for)

As far as I understand, a region can be what you want; it can cover a entire layer, or just a small part (like the preview for plug-ins. Have a look here:

http://developer.gimp.org/writing-a-plug-in/2/index.html

When you have initialized a region, you can access it pixel by pixel, row by row, or tile by tile, depending what you want to do (I guess each method has advantages, according to the filter you want to write).

I think it's important to mention that if your algorithm supports it, using pixel_regions_process () or the new gimp_rgn_iterate() functions is by far the easiest and best performing way to use pixel regions. If you use them on more than one pixel region, the regions are "registered" such that through each iteration, all of the regions are pointing to the same part. This makes operations like copying from one layer to another a snap to write. You might want to look at tile.c or threshold_alpha.c in the plug-ins/common directory for some examples.

Rockwalrus