Brightness
This algorithm adjusts the brightness of specified image in RGB color space. This algorithm works by increasing every pixel's RGB values by the specified adjust value.
Public Shared Sub ApplyBrightness(ByRef bmp As Bitmap, brightnessValue As Byte)
Dim bmpData As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb)
Dim ptr As IntPtr = bmpData.Scan0
Dim stopAddress As Integer = CInt(ptr) + bmpData.Stride * bmpData.Height
Dim val As Integer = 0
While CInt(ptr) <> stopAddress
val = Marshal.ReadByte(ptr + 2) + CInt(brightnessValue)
If val < 0 Then
val = 0
ElseIf val > 255 Then
val = 255
End If
Marshal.WriteByte(ptr + 2, CByte(val))
val = Marshal.ReadByte(ptr + 1) + CInt(brightnessValue)
If val < 0 Then
val = 0
ElseIf val > 255 Then
val = 255
End If
Marshal.WriteByte(ptr + 1, CByte(val))
val = Marshal.ReadByte(ptr) + CInt(brightnessValue)
If val < 0 Then
val = 0
ElseIf val > 255 Then
val = 255
End If
Marshal.WriteByte(ptr, CByte(val))
ptr += 3
End While
bmp.UnlockBits(bmpData)
End Sub
Example
DIm b As Bitmap = CType(Image.FromFile("rose.jpg"), Bitmap)
ApplyBrightness(b, 50)