LabVIEW Color Box to Number Conversion

Updated Aug 18, 2023

Reported In

Software

  • LabVIEW Full

Issue Details

In LabVIEW, a color box (or color in general) is actually represented by a numeric value. How does LabVIEW convert from a numeric to a color?

Solution

A color in LabVIEW is represented by a 32-bit integer. You can separate this 32-bit integer into four U8 integers:
  • Transparency, where 0 is solid and 1 is transparent. Please note that most color boxes will not accept a transparent input - you will need to keep this first integer as 0 to result in a valid color.
  • Red (any integer from 0 to 255)
  • Green (any integer from 0 to 255)
  • Blue (any integer from 0 to 255)
Another helpful representation of a color number in LabVIEW is using a HEX-formatted display. In this case, the color will be represented as AABBCC, where AA, BB and CC respectively represent the hexadecimal representation of the red, blue and green components of the color box.

Additional Information

If you have a color that you would like to programmatically change, you will need to resolve it into its RGB components by using the Color to RGB.vi function:

After doing your desired modifications to the red, green and blue components, you will be able to recombine them into a color box using a combination of Join Numbers functions (make sure to include 0 for Transparency), or using the RGB to Color.vi function as follows: