LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to read an XControl icon from disk?

Any way to read an XControl icon (same one that shows up in the controls palette) from disk, without loading it into  memory?


Thanks!

0 Kudos
Message 1 of 16
(12,078 Views)

Hi Jim

This is the way I did it in the past, before the normal API was provided.

I assume that the icon has a black frame and I do a string match of the file content.

Maybe not the best way, but it often works 🙂

//Mikael

Download All
0 Kudos
Message 2 of 16
(4,033 Views)

Hey Mike,


Thanks for posting this.  Is the icon data for an XControl stored in the Facade VI?  Or, is it stored in the *.xctl file in the the "NI.Lib.Icon" property (<Property Name="NI.Lib.Icon" Type="Bin"></Property>)?


Thanks,

-Jim

0 Kudos
Message 3 of 16
(4,033 Views)

In the xml file xctl, you only have the header that could be applied to all members.

But I'm not sure that the Facade VI icon is used in the palette or not, I'm just assuming that 🙂

//Mikael

0 Kudos
Message 4 of 16
(4,033 Views)

I just did a test in LV2009 and it seems that the library icon is used for the palette.

Anyone know what is the encoding of the binary data in the NI.Lib.Icon XML property?

I created a VI (attached) that reads this data from the XCTL file, but I'm not sure of the encoding (after unescaping the XML escape codes).  It doesn't look like base64, hex, etc.

Thanks,

0 Kudos
Message 5 of 16
(4,033 Views)

I'm quite sure it's a compressed binary data string.

First you have to replace the &gt; &lt; &amp; characters, then you have to figure out which compression type is used.

Maybe there is a Scripting Node for this.

//Mikael

0 Kudos
Message 6 of 16
(4,033 Views)

Hi Jim

The X Control Icon is the Library Icon in the palette, which is not that great, so please vote for my idea here (end shameless plug)

Here is a start.

Seems data is located in two spots.

I can construct the data from the file for the banner.

But there is some other unknown data.

The second tag is only created (I think) when the Library is opened in IE 2009.

(I had a case/issue/bug causing "corrupt data" with the IE API, so now I am thinking this was likely the reason)

Icon.png

Props to Vugie who initially help me with my query on LAVA

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 7 of 16
(4,033 Views)

That second tag is the layer data used by the new Icon Editor. When you edit an icon, you may have many layers of graphical information. That's only needed by the editor. All the layers are flattened out to produce the banner icon.

I'm very surprised that you're able to read the data for the icon... I tried helping Jim Kring with this last night by looking at the LV source code for where we save the library icon, and the string passes through a zip compression function before being written to the file. If your library is old enough, we don't do that -- I think that compression was added new in LV 2009, so if the library is from before then, you don't have the compression layer to deal with.

0 Kudos
Message 8 of 16
(4,033 Views)

Any chance of posting any of the compression code to read the first tag?

Also, given I was able to construct the banner from the last 3072 points, do you know what the first ~148 characters are in the NI_IconEditor tag?

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 9 of 16
(4,033 Views)

Since AristosQueue mentions ZIP compression, I would simply try it with the ZLIB Inflate function from the OpenG lvZIP package. There might be a good chance that the first 4 bytes in the stream are the actual size of the uncompressed string and need to be removed before passing to ZLIB Inflate and if you want to use that number to pass to ZLIB Inflate you would likely have to care about Endianess of that number, but I would not expect other sneaky additions to the data stream, as I doubt that the LabVIEW developers intended to make this data a big secret.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 16
(4,033 Views)