I believe this will do what you want:
public void PaintVignette(Graphics g, Rectangle bounds) { Rectangle ellipsebounds = bounds; ellipsebounds.Offset(-ellipsebounds.X, -ellipsebounds.Y); int x = ellipsebounds.Width - (int)Math.Round(.70712 * ellipsebounds.Width); int y = ellipsebounds.Height - (int)Math.Round(.70712 * ellipsebounds.Height); ellipsebounds.Inflate(x, y); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipsebounds); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.WrapMode = WrapMode.Tile; brush.CenterColor = Color.FromArgb(0, 0, 0, 0); brush.SurroundColors = new Color[] { Color.FromArgb(255, 0, 0, 0) }; Blend blend = new Blend(); blend.Positions = new float[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }; blend.Factors = new float[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f }; brush.Blend = blend; Region oldClip = g.Clip; g.Clip = new Region(bounds); g.FillRectangle(brush, ellipsebounds); g.Clip = oldClip; } } } public Bitmap Vignette(Bitmap b) { Bitmap final = new Bitmap(b); using (Graphics g = Graphics.FromImage(final)) { PaintVignette(g, new Rectangle(0, 0, final.Width, final.Height)); return final; } }
What's going on here? First, I wrote code that would fill the rectangle with an elliptical gradient brush that went from white to black. Then I changed the code so that the filled area also included angles. I did this by increasing the size of the rectangle by the difference between the dimensions of the rectangle and the dimensions of the rectangle sqrt (2) / 2 *.
Why sqrt (2) / 2? Since the point (sqrt (2) / 2, sqrt (2) / 2) is a 45 degree angle point on a unit circle. Scaling in width and height gives the distance needed to inflate the rectangle to make sure it is completely covered.
Then I adjusted the gradient blend to be much whiter in the center.
Then I changed the color from white to pure transparent black and from black to pure opaque black. This results in painting the extreme corners of black and the shadow lower along the path to the center.
Finally, I wrote a utility method that works on Bitmap (I did not test this part - I checked the code on the chart from the panel, but I think it will work here too.