static void FillPixels ( Brush brush, Rect [] rects, int width, int height, ref int [] pixels ) { if (width < 1 || height < 1) throw new ArgumentNullException (); var brushPixels = brush.GetTextureData(width, height); var getBrushPixel = new Func<int, int, Color>( (x, y) => { return new Color { PackedValue = (uint)brushPixels[Math.Min ( y, height - 1 ) * width + x] }; }); foreach (var rc in rects) { for (var x = (int)rc.Left; x < rc.Right && rc.Right <= width; x++) { var pixelTopColor = new Color { PackedValue = (uint)pixels [((int)rc.Top) * width + x] }; var pixelBottomColor = new Color { PackedValue = (uint)pixels [((int)rc.Bottom-1) * width + x] }; var topColor = getBrushPixel(x, (int)rc.Top);//brush.GetPixel (x, (int)rc.Top, width, height); var bottomColor = getBrushPixel(x, (int)rc.Bottom); //brush.GetPixel (x, (int)rc.Bottom, width, height); // Antialiazing, Top /* if (rc.Top > 0 ) { pixels [((int)rc.Top - 1) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .65f).PackedValue; } */ if (rc.Top > 1) { pixels [((int)rc.Top - 2) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .38f).PackedValue; } for (var y = (int)rc.Top; y < rc.Bottom; y++) { pixels [y * width + x] = ( int ) ( getBrushPixel ( x, y ) ).PackedValue; } // Antialiazing, Bottom if (rc.Bottom < height) pixels [((int)rc.Bottom) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .65f).PackedValue; /* if (rc.Bottom < height - 1) pixels [(int)(rc.Bottom + 1) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .38f).PackedValue; */ } } }