Graphics.GetNearestColor Method
Assembly: System.Drawing (in system.drawing.dll)
public Color GetNearestColor ( Color color )
public function GetNearestColor ( color : Color ) : Color
Not applicable.
Parameters
- color
Color structure for which to find a match.
Return Value
A Color structure that represents the nearest color to the one specified with the color parameter.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
-
Creates an arbitrary color with ARGB coordinates (255, 165, 63, 136).
-
Creates a solid brush and sets its color to the specified color.
-
Fills an ellipse using the arbitrary color.
-
Creates a second color and sets its value to the nearest system ARGB color.
-
Fills a second ellipse with this color.
The result is two ellipses: the first drawn with the arbitrary specified color and the second drawn with the system color nearest the specified color.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.