Sign in to follow this  
BoltBait

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!

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites

See, that's what I was thinking, although...

Yeah, you're technically working with 8x the original memory (or maybe nine...) and that's w/ 1 px feather...

Share this post


Link to post
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? ;)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this