كود :
Public Shared Function Light(ByVal img As System.Drawing.Image, ByVal col As System.Drawing.Color, ByVal opacity As Single, Optional ByVal direction As Drawing2D.LinearGradientMode = Drawing2D.LinearGradientMode.ForwardDiagonal) As System.Drawing.Image
Dim rectangle As Rectangle
Dim image As New Bitmap(img.Width, img.Height)
Using graphics As Graphics = graphics.FromImage(image)
rectangle = New Rectangle(0, 0, img.Width, img.Height)
Dim brush As New Drawing2D.LinearGradientBrush(rectangle, col, Color.Transparent, direction)
graphics.FillRectangle(brush, rectangle)
End Using
Using graphics2 As Graphics = Graphics.FromImage(img)
Dim imageAttr As New Imaging.ImageAttributes
Dim newColorMatrix As Single()() = New Single()() {New Single() {2.0!, 0.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 1.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 1.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 0.0!, opacity / 100, 0.0!}, New Single() {0.2!, 0.2!, 0.2!, 0.0!, 1.0!}}
Dim matrix As New Imaging.ColorMatrix(newColorMatrix)
imageAttr.SetColorMatrix(matrix, Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Bitmap)
rectangle = New Rectangle(0, 0, img.Width, img.Height)
graphics2.DrawImage(image, rectangle, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr)
End Using
Return img
End Function