LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can one (re)define the colorbox to have any 16bit output?

Solved!
Go to solution

Open the xcontrol example with the thermometer (search the example finder). An Xcontrol is a controls with a defined datatype (e.g U16 in your case) but what the user sees can be anything (e.g. 3 small numeric control for RGB and a colorbox showing the resulting color in your case)  and the look can depend on if we use it as control or indicator. It contains all the math to converts whetever the users sees or operates (can be anything!) to the U16 datatype and back. Once you create the xcontrol, you can use it like a regular control. It even reacts correctly when the parent Vi is in edit mode.

 

Creating XControls

0 Kudos
Message 11 of 21
(4,932 Views)

This would be less Rube Goldberg code.    24RGB to 16BGR.png

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 12 of 21
(4,913 Views)
Solution
Accepted by topic author ghighuphu

Rolf's snippet is a far cleaner bit manipulation then was I was talking out in my message.  Taking that and adding Altenbach's suggestion of showing the actual resulting color that gets encoded in the 16 bits, I get this.

 

Message 13 of 21
(4,908 Views)

Thank you for pointing out on my Rube Goldberg code 🙂

 

I implemented RavensFan's solution, but it does not work for white and colours close to white (grey), see screenshot, please.

white does not work as expected.png

 

Below is the code, please.

code.png

 

Additional questions:

* How do I make LabView display the zeros at the begining of the binary number? The number constant in question is labeled "bits accepted for U16" in my code, no label in RavensFan code.

* Again, how do I make LabView display all the characters (zeros) in the hexadecimal number? That is, in both and only hexadecimal numbers in the code "U32 Colour Number In" and "U32 Colour Number Out").

Message 14 of 21
(4,875 Views)

Ok, so I found the answer to show the whole binary number: in the display properties to the constant, there is the option to pad wioth zeros from the left. The same is applicable for th hex-strings.

0 Kudos
Message 15 of 21
(4,870 Views)

The color you show as white is not an RGB code but a special LabVIEW code. Notice the most significant bit bit 24 (25th bit) being set to 1. With that bit set the lower significnt 16 bits are really just an index into the LabVIEW predefined colors for things like dialog background, highlight color, etc. Which also depend on your currently selected platform GUI theme. I believe 0x1000000 is transparent, which for various reasons can't be everywhere used such as for fill colors in most objects, since it is not possible to draw transparent, but instead requires the draw algorithme to inverse the normal draw logic in many situations.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 16 of 21
(4,864 Views)

In my Message 14, the output is falsely assigned in the attached VI. This was the reason for false output. Thank you all!

 

Edit: No, it was is not the only error. I do not understand: the white colour is still as black at the U16 output.

Message 17 of 21
(4,820 Views)

As Rolf said, you picked a "special" color.  A u32 that maps to the windows system settings color.  It isn't white, it is "Panel & Object" that would be selected from the System section of the lower right part of the Color Picker dialog box.  Once you strip off the highend byte (the one  before the RGB), you are left with something closer to black.

 

You need to pick your white of the regular "User" colors, or using the Palette button that let's you pick a custom color out of the color dialog box.

Message 18 of 21
(4,795 Views)

Thank you RavensFan for pointing me to the right direction -- I think, I was (still) lost in translation when reading Rolf's explanaition for the third time.

 

I've found only another single post, where the user was also mislead by a system color http://forums.ni.com/t5/LabVIEW/System-colors-do-not-give-correct-RGB-values/m-p/868863/highlight/tr...

 

Would it make any sense, if I wished for a colorbox, which would state a non-standard color? E.g. by drawing a giant "S" in the box, similar to "T" for transparent. <- That's a hypotetical question. I am thinking of posting a LabVIEW Idea post about it.

0 Kudos
Message 19 of 21
(4,772 Views)

There might be some value in having a color box for a system color indicate that in some manner.  I don't think the "S" would work because if the text was black (like the Transpare "T"), it would show up for a system white, but disappear in a system black or other dark color.

0 Kudos
Message 20 of 21
(4,768 Views)