LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Boolean Image with Alpha - Get Array Element Background Color

Solved!
Go to solution

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.

0 Kudos
Message 1 of 12
(2,217 Views)

A little janky, but you can get the reference to the boolean text and extract its background color:

 

BertMcMahan_0-1705618760911.png

 

Message 2 of 12
(2,199 Views)

Some things just aren't accessible through property/invoke nodes.  Here's my kludge:

ac.png

Message 3 of 12
(2,153 Views)

I amc urious about what this is actually useful for? Do you want to display this on some dedicated display?

Actor Framework
0 Kudos
Message 4 of 12
(2,129 Views)

Paul I think I like your method more.  I didn't realize you could make the array elements hidden that might work more reliably since getting the background color is also helpful when other controls are in the array.  Still I did try some other array types and got weird colors using your method.  I think I'll hide the array elements, then get the image size, but then try to pick the center pixel (divide width by 2 then height by 2) then pick that color.  How was the divide by 3 you used, supposed to work?  I get that there are 3 bytes per pixel but where in the image are getting the color from?  I'd want to avoid the edges since the array will likely have some kind of a border.  Since there are an unknown number of rows or columns being shown I thought staying in the center would fix that.

 

@Quiztus2 wrote:

I amc urious about what this is actually useful for? Do you want to display this on some dedicated display?


This is for a pet project I've worked on, off and on over the years.  It converts a VIs front panel to a web page that you can interact with.  I'm making pretty good progress but it is one of those things that I'll never get 100% complete on.  Here is the last public release a while ago.

0 Kudos
Message 5 of 12
(2,093 Views)

@Hooovahh wrote:

Paul I think I like your method more.  I didn't realize you could make the array elements hidden that might work more reliably since getting the background color is also helpful when other controls are in the array.  Still I did try some other array types and got weird colors using your method.  I think I'll hide the array elements, then get the image size, but then try to pick the center pixel (divide width by 2 then height by 2) then pick that color.  How was the divide by 3 you used, supposed to work?  I get that there are 3 bytes per pixel but where in the image are getting the color from?  I'd want to avoid the edges since the array will likely have some kind of a border.  Since there are an unknown number of rows or columns being shown I thought staying in the center would fix that.

 

@Quiztus2 wrote:

I amc urious about what this is actually useful for? Do you want to display this on some dedicated display?


This is for a pet project I've worked on, off and on over the years.  It converts a VIs front panel to a web page that you can interact with.  I'm making pretty good progress but it is one of those things that I'll never get 100% complete on.  Here is the last public release a while ago.


Dividing by 3 ensures that the R, G, B boundaries line up.  Off the top of my head I figured that would grab a point 1/3 the way down and 1/3 the way over.  Maybe that's not correct and it sometimes grabs a pixel near the edge.

0 Kudos
Message 6 of 12
(2,077 Views)

I expected this to work, but it's way off and I don't see the error.

cp.png

0 Kudos
Message 7 of 12
(2,050 Views)
Solution
Accepted by topic author Hooovahh

The red dots were killing me.

Here is is fixed up (I also simplified the math and the BD),

ab.png

Message 8 of 12
(2,017 Views)

And now for a styling question: Which looks better:

A:

paul_a_cardinale_0-1705934812387.png

 

B:

paul_a_cardinale_1-1705934831085.png

 

0 Kudos
Message 9 of 12
(1,944 Views)

I like A better, but it really doesn't matter.

0 Kudos
Message 10 of 12
(1,941 Views)