Jon Skeet provided this solution in the MS Windows Forms News Group.
[C#]
double greyLevel = original.R * 0.299 + original.G * 0.587 + original.B * 0.144;
if (greyLevel > 255)
{
greyLevel = 255;
}
Color desaturated = new Color.FromArgb((byte)greyLevel, (byte)greyLevel, (byte)greyLevel);
[VB.NET]
Dim greyLevel As Double = original.R * 0.299 + original.G * 0.587 + original.B * 0.144
If greyLevel > 255 Then
greyLevel = 255
End If
Dim desaturated As New Color.FromArgb(CByte(greyLevel), CByte(greyLevel), CByte(greyLevel))
Share with