Table of Contents

23.4.2.2 Class ColorInfo

The ColorInfo (gb.image) class presents detailed information about a colour, among other things. The class has the properties Alpha, Colour, Red, Green, Blue, Hue, Saturation and Value, which you can read or set. The data type for all properties is Integer.

23.4.2.2.1 Properties

The following table describes the above properties of the class:

ColourInfoIntervalDescription
Alpha0..255Defines the alpha value or returns the value.
Color 0..256³-1Specifies the full colour value of the ColorInfo object or returns the value.
Red0..255Specifies the red component of the colour or returns the value → RGB colour space
Green0..255Specifies the green component of the colour or returns the value → RGB colour space
Blue0..255Specifies the blue component of the colour or returns the value → RGB colour space
Hueö0..359Specifies the hue component of the colour or returns the value → HSV colour space
Saturation0..255Specifies the saturation of the colour or returns the value → HSV colour space
Value0..255Specifies the brightness component of the colour or returns the value → HSV colour space

Table 23.4.2.2.1 : Properties of the ColorInfo (gb.image) class

23.4.2.2.2 Examples

You get iColor for any colour with

Color[iColor]

a ColorInfo object from which you can read the RGB and HSV information of the colour space used and the value for the alpha channel or set the RGB and HSV colour components!

You must then generate the modified colour from the colour components, whereby the unmodified colour components are read out and applied either with Color[iColor].Green and Color[iColor].Blue or with hColorInfo.Green and hColorInfo.Blue:

Public Sub btnColorChange_Click()
 
    Dim iColor As Integer
    Dim hColorInfo As ColorInfo
 
    iColor = CChooser1.SelectedColor	'-- Synonym for iColor = CChooser1.Value
    hColorInfo = Color[iColor] 		'-- A ColorInfo object is returned
'-- Print Color[iColor].Red 		'-- Reading out the red colour component with the [] operator
'-- Print hColorInfo.Red 			'-- Read out red colour component (alternative)
    hColorInfo.Red = 180 			'-- Change red colour component
    hColorInfo.Alpha = 140			'-- Change alpha value
'-- Print hColorInfo.Red 			'-- Read out the current red colour component
'-- Print hColorInfo.Alpha 		'-- Read out the current alpha value
    CChooser1.Value = Color.RGB(hColorInfo.Red, Color[iColor].Green, hColorInfo.Blue, hColorInfo.Alpha)
'-- Good alternative: CChooser1.Value = hColorInfo.Color
 
End

Note: The complex SetRGB(..) and SetHSV(..) methods of the Color (gb.image) class - which you can use to change the RGB(A) colour component or HSV(A) colour component for each colour individually(!) - are faster and therefore preferable:

Public Sub btnSetRGB_Click()
 
  Dim iColor As Integer
 
  iColor = CChooser1.SelectedColor
  CChooser1.SelectedColor = Color.SetRGB(iColor, 180, Color[iColor].Green, Color[iColor].Blue, 140)
 
End