您可以使用 ColorMatrix 和 ImageAttributes 更快地完成它。就是这样:
Imports System.Drawing.Imaging
Public Class Form1
Dim g As Graphics
Dim img As Image
Dim r As Rectangle
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' load photo file into picture box and initialize graphics
img = Image.FromFile("c:\tmp.jpg")
PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height, PixelFormat.Format32bppArgb)
g = Graphics.FromImage(PictureBox1.Image)
r = New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height)
g.DrawImage(img, r)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call setBrightness(0.2)
End Sub
Sub setBrightness(ByVal Brightness As Single)
' Brightness should be -1 (black) to 0 (neutral) to 1 (white)
Dim colorMatrixVal As Single()() = { _
New Single() {1, 0, 0, 0, 0}, _
New Single() {0, 1, 0, 0, 0}, _
New Single() {0, 0, 1, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {Brightness, Brightness, Brightness, 0, 1}}
Dim colorMatrix As New ColorMatrix(colorMatrixVal)
Dim ia As New ImageAttributes
ia.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap)
g.DrawImage(img, r, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia)
PictureBox1.Refresh()
End Sub
End Class