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

Selections in plugins

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.

6 of 6 messages available
Toggle history

Please log in to manage your subscriptions.

Selections in plugins Joël-Alexis Bialkiewicz 26 Jan 11:25
  Selections in plugins Simon Budig 26 Jan 11:35
   Selections in plugins Joël-Alexis Bialkiewicz 26 Jan 11:49
    Selections in plugins Simon Budig 26 Jan 12:20
     Selections in plugins Joël-Alexis Bialkiewicz 28 Jan 09:50
      Selections in plugins Simon Budig 28 Jan 17:19
Joël-Alexis Bialkiewicz
2006-01-26 11:25:59 UTC (about 18 years ago)

Selections in plugins

I need to implement an inpainting algorithm as a gimp plugin.

I am going to start coding very soon.

I read the plugin-template, and the plugin development tutorial, but I still have a problem figuring how selections are managed by the GIMP.

I experimented with the dummy plugin (blur) given in the tutorial, and it appears to work perfectly with complex (ie, non-square) selections, including complex selections. Still, the code is two for loops imbricated, which means it computes over a square. It never calls a test function to know if a given coordinate is selected or not.

The tutorial says that "thanks to the GIMP core, it already takes selection into account" but doesn't say how.

My primary hypothesis is that gimp gives the full image (or a square portion of it including all selections) when you call gimp_drawable_mask_bounds, and that when you write your results using gimp_drawable_update, it just updates the selected portion of this square.

There come my questions : A) Have I figuret it correctly?
B) If not, how does it really work?
C) Is there a way to force writing outside the selection? D) Is there a way to know if a given coordinate is selected or not?

Thanks to all for your kind advice.

-- Joel-Alexis Bialkiewicz

Simon Budig
2006-01-26 11:35:58 UTC (about 18 years ago)

Selections in plugins

Joël-Alexis Bialkiewicz (jabial@gmail.com) wrote:

My primary hypothesis is that gimp gives the full image (or a square portion of it including all selections) when you call gimp_drawable_mask_bounds, and that when you write your results using gimp_drawable_update, it just updates the selected portion of this square.

There come my questions : A) Have I figuret it correctly?
B) If not, how does it really work?
C) Is there a way to force writing outside the selection? D) Is there a way to know if a given coordinate is selected or not?

The selection gets respected when you're using shadow tiles and use gimp_drawable_merge_shadow. You can ignore the selection by not using shadow tiles IIRC, I am at the moment not sure how this would affect the undo system if you don't use shadow tiles.

Hope this helps a bit, Simon

Joël-Alexis Bialkiewicz
2006-01-26 11:49:18 UTC (about 18 years ago)

Selections in plugins

On 1/26/06, Simon Budig wrote:

The selection gets respected when you're using shadow tiles and use gimp_drawable_merge_shadow. You can ignore the selection by not using shadow tiles IIRC, I am at the moment not sure how this would affect the undo system if you don't use shadow tiles.

In fact I don't want to ignore selections but to use them in a different way. Especially, I would like to be able know, for a specific point, whether it is selected or not.

Simon Budig
2006-01-26 12:20:17 UTC (about 18 years ago)

Selections in plugins

Joël-Alexis Bialkiewicz (jabial@gmail.com) wrote:

On 1/26/06, Simon Budig wrote:

The selection gets respected when you're using shadow tiles and use gimp_drawable_merge_shadow. You can ignore the selection by not using shadow tiles IIRC, I am at the moment not sure how this would affect the undo system if you don't use shadow tiles.

In fact I don't want to ignore selections but to use them in a different way. Especially, I would like to be able know, for a specific point, whether it is selected or not.

You can request the selection as a drawable using gimp_image_get_selection(). You then can peek into this drawable to get the selection value for a specific pixel. You probably need to be careful with the offset handling a bit though.

Hope this helps, Simon

Joël-Alexis Bialkiewicz
2006-01-28 09:50:15 UTC (about 18 years ago)

Selections in plugins

On 1/26/06, Simon Budig wrote:

Joël-Alexis Bialkiewicz (jabial@gmail.com) wrote:

In fact I don't want to ignore selections but to use them in a different way. Especially, I would like to be able know, for a specific point,

whether

it is selected or not.

You can request the selection as a drawable using gimp_image_get_selection(). You then can peek into this drawable to get the selection value for a specific pixel. You probably need to be careful with the offset handling a bit though.

1) What do you mean by careful with the offset handling? 2) When I read the data from the selection drawable, 1 means selected and 0 means not selected, isn't it?
3) When I call gimp_drawable_mask_bounds and there is a complex selection, what part of the image does it point out to me? Does it correspond the littlest square possible containing all selected points? 4) When I try to read a point that is not selected, will it give me the right value for this point or some dummy value?

Thanks in advance.

Sincerely, Joel-Alexis Bialkiewicz

Simon Budig
2006-01-28 17:19:41 UTC (about 18 years ago)

Selections in plugins

Joël-Alexis Bialkiewicz (jabial@gmail.com) wrote:

On 1/26/06, Simon Budig wrote:

Joël-Alexis Bialkiewicz (jabial@gmail.com) wrote:

In fact I don't want to ignore selections but to use them in a different way. Especially, I would like to be able know, for a specific point,

whether

it is selected or not.

You can request the selection as a drawable using gimp_image_get_selection(). You then can peek into this drawable to get the selection value for a specific pixel. You probably need to be careful with the offset handling a bit though.

1) What do you mean by careful with the offset handling?

Layers are not necessarily at the 0,0 position of the canvas. The selection however is. So you need to take that difference into account.

2) When I read the data from the selection drawable, 1 means selected and 0 means not selected, isn't it?

A selection is not binary. 255 means selected, 0 means not selected, 100 means "partially selected".

3) When I call gimp_drawable_mask_bounds and there is a complex selection, what part of the image does it point out to me? Does it correspond the littlest square possible containing all selected points?

this returns the bounding box, All pixels outside are *not* selected, there may be not selected pixels inside.

4) When I try to read a point that is not selected, will it give me the right value for this point or some dummy value?

When reading the pixels from a drawable the selection does not affect the result. You always get the correct result (under the assumption that you do read correctly...)

Hope this helps, Simon