Jump to content

Get connector pane 32x32 image - looking for better idea


Recommended Posts

Hi,

 

I'm building a BatchEditor to bulk edit/verify for style many LV files at once (projects, VIs, controls, folders etc.). For that I need to get the 32x32 pixel connector pane image. Not the icon (I can get that with the public VI Icon.Get As Image Data method), and not the image from context help (I can get that with the private Get Conpane Image method for instance). Instead, look at the output of my VI here:

 

post-15239-0-54597200-1361355285.png

 

I do that by scripting a new VI, dropping in my subject VI as subVI, then showing that subVI's terminal image instead, then grabbing the image from there:

 

post-15239-0-59697800-1361355893_thumb.p

 

In case you're wondering; the 32x32 pixel "Black frame icon" is set to get correct conpane images of subVIs that are smaller than 32x32 pixels to start with... But, this entire scripting approach is slow and convoluted, do any of you guys have a better idea to get this image?

 

Cheers,

Steen

Link to comment

Yes I have, the 'Export Interface' method returns the same image as the 'Get Conpane Image' method. That is, the icon (not conpane "icon") including any controls and indicators connected to the conpane. It doesn't include the VI Description text either, which I had actually expected (to the extent that you can expect anything from private methods).

 

That method is also a bit funny as it's marked as "Deprecated" (as in your image) when imported from an earlier LV version, even though it's still present, and selectable, with the exact same name in LV 2012 for instance.

 

/Steen

Edited by Steen Schmidt
Link to comment

There is another option I can think of, but I don't know if its performance will be any better - Get the VI's connector pane reference and use that to get the reference to the controls and the pattern. Then, use those reference and call the Application class method Data Type Color to get the color for each terminal and then draw the connector yourself based on the pattern. I'm assuming that the color is the one which actually appears in the con pane. You might be able to use code people already uploaded to make editing the con pane easier (I believe Mark Balla has one in the CR).

  • Like 1
Link to comment

I'm not sure why the "Get Conpane Image" private method is not working. (not private in LV2012)

 

I've seen this used in Marc Page's Polish VIs library available on the NI forums.

 

https://decibel.ni.com/content/docs/DOC-1189

 

I just downloaded it and tested with both LabVIEW 8.6 and 2012 and the method worked fine.

Edited by Phillip Brooks
Link to comment

ShaunR: The Icon Editor isn't helping either. It doesn't get the conpane image really, it builds a slightly larger terminals outline image programmatically from conpane info. This conpane info is publically available, and I could use that to create my own conpane image... And then we're at what Yair suggests, namely that I build this image manually instead of grabbing it from somewhere, and hoping this process is faster than what I do now with scripting. The programming involved is quite extensive pixel-chipping though, so I think I'll stick with what I currently have and use those hours on something else in the BatchEditor.

 

Thanks for your suggestions :-)

 

Cheers,

Steen

Link to comment

Thanks Phillip,

 

I have worked a bit with Darren's VI, and it's slightly faster than scripting a subVI, but the created conpane image does not look 100% correct, as some of the terminal borders are thicker than normal (2px vs. 1px). But your link gave me an idea; I could combine Darren's approach of making the colored rectangles in an empty image, and then just superimpose the proper conpane "frame" on top of that image (instead of drawing a slightly wrong rectangle around each terminal position).

 

The only drawback is that I'll be supporting a static set of conpane patterns then. On the other hand, once the conpane patterns eventually gets updated, my whole BatchEditor will probably have to be rewritten anyway.

 

I'll take a look at it tomorrow - it's getting close to midnight here.

 

Cheers,

Steen

 

Update: Superimposing the conpane frame doesn't work correctly either. Output terminals should have 2px wide borders in the conpane image, while inputs and unwired terminal borders should have 1px wide borders. And it's of course not possible to have all possible conpane image combinations of I/O prepared statically. Back to the drawing board, or stay with the scripting approach...

Edited by Steen Schmidt
Link to comment
I have worked a bit with Darren's VI, and it's slightly faster than scripting a subVI, but the created conpane image does not look 100% correct, as some of the terminal borders are thicker than normal (2px vs. 1px). But your link gave me an idea; I could combine Darren's approach of making the colored rectangles in an empty image, and then just superimpose the proper conpane "frame" on top of that image (instead of drawing a slightly wrong rectangle around each terminal position).
Update: Superimposing the conpane frame doesn't work correctly either. Output terminals should have 2px wide borders in the conpane image, while inputs and unwired terminal borders should have 1px wide borders. And it's of course not possible to have all possible conpane image combinations of I/O prepared statically. Back to the drawing board, or stay with the scripting approach...

 

There is a lot of funny business going on with the terminal bounds and with the Draw Rectangle vi.  On the surface, it appears the TermBnds[] property is wrong because it returns value between 0,0 and 32,32 which means a size of 33x33.  However, Draw Rectangle does not really use the values of right and bottom, it actually gives rectangles with the width and height specified (for line width = 1).  For example, if you draw the rectangle from (0,0) to (8,8) and look at the 1-bit pixmap you will see that the pixel indices are 0,0 to 7,7.  When you turn around and draw a second rectangle from (8,0) to (16,8) you get a second line at column 8 in the 1-bit pixmap, ie. a double-width line.  What a mess.

 

An easy "fix" is to compensate by adding 1 to the right and bottom values.  Now you get a nice conpane outline with all single pixel lines.  The only problem is that it is now 33x33 pixels (if you care).

  • Like 1
Link to comment

Thanks to everyone in this thread, especially you Darren, who had a VI on your shelf showing that I should just have done what Yair suggested :lol:.

 

I've basically reworked Darren's VI, into one that creates a 100% correct conpane image. Here's the FP illustrating an example (the VI itself is attached this post if you can use it):

 

post-15239-0-47841600-1361453776.png

 

So that's probably the fastest way in G to get the conpane image. I discovered a funny thing while coding this; the Get Image method of the SubVI class returns slightly wrong terminal colors for the conpane image!

 

post-15239-0-54270400-1361455136.png

 

For instance "Boolean green" is RGB 0,127,0 in the BD, but the image when extracted with the Get Image method contains a slightly darker green color, namely 0,102,0 instead. So an unexpected side effect by this small exercise were even more correct conpane images :).

 

Cheers,

Steen

GetConpaneImage.vi

  • Like 1
Link to comment
I discovered a funny thing while coding this; the Get Image method of the SubVI class returns slightly wrong terminal colors for the conpane image!

 

 

I'm pretty sure that the default color depth for the method is 8 bits, so you get a limited palette. Try using 24 bits.

  • Like 2
Link to comment
I just did a manual test (I pasted the generated image into Paint.NET) and it does seem to work - feeding 24 into the Image Depth input generates an image where the boolean terminal is 0,127,0.

 

I'll be...... I just tried it again and now it works? Well, must've been grimlins then. Or perhaps a Schrödinger's Cat problem...

 

/Steen

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
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.