Title | Use a LinearGradientBrush with and without gamma correction in VB .NET |
Description | This example shows how to use a LinearGradientBrush with and without gamma correction in VB .NET. Gamma correction adjusts the blended colors to make them have a more uniform brightness. |
Keywords | LinearGradientBrush, GammaCorrection, gamma correction, color, drawing, blend |
Categories | VB.NET, Graphics |
|
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
' Make the basic brush.
Dim x1 As Integer = 10
Dim x2 As Integer = Me.ClientSize.Width - 10
Dim the_brush As LinearGradientBrush
the_brush = New LinearGradientBrush( _
New Point(x1, 0), New Point(x2, 0), _
Color.Black, Color.White)
' Fill a rectangle without gamma correction.
e.Graphics.DrawString("Without Gamma Correction", _
Me.Font, Brushes.Black, x1, 10)
e.Graphics.FillRectangle(the_brush, x1, 30, x2 - x1, 40)
' Fill a rectangle with gamma correction.
the_brush.GammaCorrection = True
e.Graphics.FillRectangle(the_brush, x1, 80, x2 - x1, 40)
e.Graphics.DrawString("With Gamma Correction", _
Me.Font, Brushes.Black, x1, 125)
End Sub
|