Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

Returns the closest color to the specified RGB value that the file can support.

Signature
C#C#
Wiki Markup
{description}
{excerpt}Returns the closest color to the specified RGB value that the file can support.{excerpt}
{signature:C#}
 public Color GetClosestColor(int red, int green, int blue)
Signature
{signature}{signature:vb.net
vb.net
}
Public Function GetClosestColor(ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer) As Color
Parameters

...

The red component of the desired color. Must be between 0 and 255.

...

The green component of the desired color. Must be between 0 and 255.

...

The blue component of the desired color. Must be between 0 and 255.

Returns

The closest color in the palette to the specified RGB value

Exceptions

...

If the given red, green, or blue value is not between 0 and 255.

Remarks

For .xls files, this will be the color in the palette that has the minimum difference between the specified RGB value and its RGB value. .xlsx files are not limited to colors in the palette, and will return a Color representing the specified RGB values exactly.

{signature}
{parameters}
{param:red}The red component of the desired color. Must be between 0 and 255.{param}
{param:green}The green component of the desired color. Must be between 0 and 255.{param}
{param:blue}The blue component of the desired color. Must be between 0 and 255.{param}
{returns}The closest color in the palette to the specified RGB value{returns}
{exceptions}
{exception:System.ArgumentOutOfRangeException}If the given red, green, or blue value is not between 0 and 255.{exception}
{remarks}
For .xls files, this will be the color in the palette that has the minimum difference between the specified RGB value and its RGB value. .xlsx files are not limited to colors in the palette, and will return a [Color] representing the specified RGB values exactly.
{remarks}
{example}{code:csharp|title=C#}
Color clr = pal.GetClosestColor(162, 221, 139);
{code}
{code:vb.net
|title=vb.net
}
Dim clr As Color = pal.GetCloestColor(162, 221, 139){code}

{example}
Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle