This document is archived and information here might be outdated.  Recommended version.


Create RGBColor Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Create RGBColor Snippet

Generate an RgbColor by specifying the amount of Red, Green and Blue.

[C#]
///<summary>Generate an RgbColor by specifying the amount of Red, Green and Blue.</summary>
/// 
///<param name="myRed">A byte (0 to 255) used to represent the Red color. Example: 0</param>
///<param name="myGreen">A byte (0 to 255) used to represent the Green color. Example: 255</param>
///<param name="myBlue">A byte (0 to 255) used to represent the Blue color. Example: 123</param>
///  
///<returns>An IRgbColor interface</returns>
///  
///<remarks></remarks>
public ESRI.ArcGIS.Display.IRgbColor CreateRGBColor(System.Byte myRed, System.Byte myGreen, System.Byte myBlue)
{
  ESRI.ArcGIS.Display.IRgbColor rgbColor=new ESRI.ArcGIS.Display.RgbColorClass();
  rgbColor.Red=myRed;
  rgbColor.Green=myGreen;
  rgbColor.Blue=myBlue;
  rgbColor.UseWindowsDithering=true;
  return rgbColor;
}
[Visual Basic .NET]
'''<summary>Generate an RgbColor by specifying the amount of Red, Green and Blue.</summary>
''' 
'''<param name="myRed">A byte (0 to 255) used to represent the Red color. Example: 0</param>
'''<param name="myGreen">A byte (0 to 255) used to represent the Green color. Example: 255</param>
'''<param name="myBlue">A byte (0 to 255) used to represent the Blue color. Example: 123</param>
'''  
'''<returns>An IRgbColor interface</returns>
'''  
'''<remarks></remarks>
Public Function CreateRGBColor(ByVal myRed As System.Byte, ByVal myGreen As System.Byte, ByVal myBlue As System.Byte) As ESRI.ArcGIS.Display.IRgbColor

  Dim rgbColor As ESRI.ArcGIS.Display.IRgbColor=New ESRI.ArcGIS.Display.RgbColorClass
  With rgbColor
    .Red=CInt(myRed)
    .Green=CInt(myGreen)
    .Blue=CInt(myBlue)
    .UseWindowsDithering=True
  End With

  Return rgbColor

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.System