int num;
void Render(Surface dst, Surface src, Rectangle rect)
{
for (int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{
num++; //for every pixel in your selection, increment this num variable
}
}
#if DEBUG
Debug.WriteLine(num);
#endif
}
If you take a look at this code, the num variable should return the amount of pixels you have selected. At first it only worked some of the time, and was confused as to why. But after some messing around I found out rect only contains the selected area visible to the user:
For example in a 64x64 image:
Running that code with the full image selected and with the full view of it
Will return the correct number of pixels, 64 * 64 = 4096
But running the code with only a part of the image visible (while still selecting it whole):
Will return the wrong number of pixels, because the effect only works on the currently visible selected area, despite still having the entire image selected.
Is there a way to get around this? without using src.Bounds and forcing a single render call (in order to work with none-rectangle selections)