private const float BRIGHTNESS = 220.0F;
Graphics g = this.pictureBox2.CreateGraphics();
g.Clear(Color.White);
Bitmap bmp = new Bitmap(this.pictureBox1.Image);
int width = bmp.Width;
int height = bmp.Height;
Bitmap tmp = bmp.Clone(new RectangleF(0, 0, width, height), System.Drawing.Imaging.PixelFormat.DontCare);
//发亮点右上角 此值会让强光中心发生偏移
Point lightP = new Point(width - 40, height / 4);
//R强光照射面的半径,即”光晕”
int radius = Math.Min(width / 2 + 60, height / 2 + 60);
for (int i = 1; i < width; i++)
for (int j = 1; j < height; j++)
{
float length = (float)Math.Sqrt(Math.Pow((i - lightP.X), 2) + Math.Pow((j - lightP.Y), 2));
//如果像素位于”光晕”之内
if (length < radius)
{
Color C = tmp.GetPixel(i, j);
int rV, gV, bV;
//亮度增加常量,该值越大,光亮度越强
float pixel = BRIGHTNESS * (1.0f - (length / radius));
rV = C.R + (int)pixel;
rV = Math.Max(0, Math.Min(rV, 255));
gV = C.G + (int)pixel;
gV = Math.Max(0, Math.Min(gV, 255));
bV = C.B + (int)pixel;
bV = Math.Max(0, Math.Min(bV, 255));
//将增亮后的像素值回写到位图
Color newC = Color.FromArgb(255, rV, gV, bV);
tmp.SetPixel(i, j, newC);
}
}
g.DrawImage(tmp, pictureBox2.ClientRectangle);// new Rectangle(0, 0, width, height));
g.Dispose();
![](//images0.cnblogs.com/blog/511414/201501/220955085311184.png)