The reason you are getting the stripes is because in your averaging code you are only taking the average of the colours in each of the rendering rectangles as opposed to the image as a whole. To take the average of every pixel your average code should look more like this
for(int y = 0; y < src.Height; y++)
{
for (int x = 0; x < src.Width; x++)
{
//TODO: your averaging code
}
}
notice how I replaced the lines "int y = rect.Top" with "int y = 0" and likewise for the rest of the bounds, this will make sure you look at every pixel in your image.
However you will only want to do this once as its very time consuming so at the start of the rendering method you can check if you need to do the averaging and then do it if you need to. On the other hand, if you are building it in VS, you should calculate the average in the OnSetRenderInfo
Another small tip, when setting the average colour to each pixel, get rid of the call if(selection.IsVisible(x, y)) because it is slow and not really necessary.
Here is a sample of something I just put together which does pretty much what you want it to do, although it doesn't use the blur algorithm from your original code and it takes the average of the whole picture regardless of the selection but you get the idea.
private bool set = false;
private ColorBgra avg;
private unsafe void Render(Surface dst, Surface src, Rectangle rect)
{
if(!set)
{
set = true;
ColorBgra[] cols = new ColorBgra[src.Height];
for(int y = 0; y < src.Height; y++)
{
ColorBgra* ptr = src.GetRowAddress(y);
cols[y] = ColorBgra.Blend(ptr, src.Width);
}
avg = ColorBgra.Blend(cols);
}
for(int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{
dst[x,y] = avg;
}
}
}
But like I said, if you build it in VS, you can put the:
ColorBgra[] cols = new ColorBgra[src.Height];
for(int y = 0; y < src.Height; y++)
{
ColorBgra* ptr = src.GetRowAddress(y);
cols[y] = ColorBgra.Blend(ptr, src.Width);
}
avg = ColorBgra.Blend(cols);
in your OnSetRenderInfo() method and remove it from the render function completely.
Have a play with that and see how it goes, if you have any more questions feel free to ask.