Jump to content

Is current pixel selected?


Recommended Posts

When running the following loop (from codelab):

void Render(Surface dst, Surface src, Rectangle rect)
{
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
       }
   }
}

How can I know if the current pixel (src[x, y] or dst[x, y]) is inside of the current selection?

With rectanglar selections, it seems easy, but when you are working with a selection created with the circle, lasso or magic wand...

Thanks!

Link to comment
Share on other sites

I think this should work ...

PdnRegion selectionRegion = this.EnvironmentParameters.GetSelection(src.Bounds);

if (selectionRegion.IsVisible(x, y))
{
   .... 
}

Note that if there is no selection, then selectionRegion will encompass the entire canvas area.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Actually ...

... x and y will always be inside the current selection.

Because effect rendering is always clipped to the current selection.

So, what are you trying to do?

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Basically, I would like to write some type of feathering filter. I need to find the 'edges' of the selection so I can fiddle with the alpha of those pixels.

Let's say I have a given pixel that I'm looking at. If any of the 8 surrounding pixels are 'outside' of the current selection and this pixel is 'inside', then I have found an edge pixel and need to change the alpha of that pixel.

When working with areas selected with the magic wand, the selection can become quite complex.

Link to comment
Share on other sites

Hrmm, I'm not so sure that'll work very well from an Effect without a dual quad core 3ghz Opteron (heh if only :twisted:). It only has access to the selection Region, not the original Path (PdnGraphicsPath).

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Hrmm, I'm not so sure that'll work very well from an Effect without a dual quad core 3ghz Opteron (heh if only :twisted:). It only has access to the selection Region, not the original Path (PdnGraphicsPath).

Seeing how I work for Intel, there's no need to be rude. :P

I'm sure I could get my hands on a Quad Core if I really needed it. :lol:

Well, I was thinking that you draw those marching ants fairly quickly, why can't I get access to that path and modify the alpha of the edge pixels just as quickly?

But, even if I can't do it quickly, I would still like to do it slowly. So, is it possible?

BTW, I think you could do it by only checking a maximum of 4 directions instead of 8. Is that better? ;)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...