Jump to content

Get Boolean Image with Alpha - Get Array Element Background Color


Recommended Posts

Crosspost

Okay so I have a front panel, with some boolean controls on it.  I want to get the image of that control, and I want to put that image on top of other images.  The background color of the other images is controllable, so if I use the Get Image invoke node method on the control reference, and just set the background color to what the background is of the pane that the boolean is on, then it is convincing enough.  But I am having issues when these boolean controls are in other controls.  If it is in a Cluster for instance I need to get the image of the background of the cluster.  Clusters can be transparent so I need to keep getting the owner controls until I find one that isn't transparent.  For bonus points I can also use the Create Mask VI to mask out a color, and I can use the color of the background element to get an even cleaner image of my boolean control.

This is all a pain but doable.  The issue I have is when my boolean is in an array.  My main goal is to just get the boolean control, with the alpha or specific colors masked out.  But when it comes to having booleans in arrays that is an issue.  Any suggestions?  Attached is a demo of what I mean.  Set the enum then run it.  For the scalar we just get the pane color.  For clusters we get the color, then if it is transparent, keep going up until we find a color, or find the pane.  But how do I handle the array?  Thanks.

Boolean Get Image Testing.vi

Link to comment
On 1/19/2024 at 3:38 PM, ShaunR said:

There is an "Element" property for arrays. You can get that then cast it to the element type. Then your other methods should work (recursion).

Thanks Shaun but this doesn't quite work like I wanted.  Maybe I didn't explain it well I can be long winded.  Using your method this is what I get:

Untitled.png.41d6712551d94303af5a36802d8a2c69.png

In this case I actually want the somewhat blue looking color since that is what the boolean is in.  The method suggested on NI's forums seems to work but is clunky but works.  It hides the array element, label, caption, and index, then gets the image of the array control.  Then gets the color of the pixel at the center of the image.  With the element hidden it just shows the background which is the color blue in this case.

As for why, I also ended up answering that on the NI forums.  It is because I wanted to improve the web controlling VI code I uploaded a while ago here.

Boolean Get Image Testing_sr.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.