LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to read an XControl icon from disk?

Thanks Rolf

I had a quick go and the Inflate function returned an error?

I also tried every combination of removing any appended data (in a for loop) and still got an error.

Anyone had any luck?

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 11 of 16
(1,064 Views)

Ok, here's what I've got so far (see screenshot and attached VI [requires OpenG Zip Tools]).  Note: It doesn't seem to work yet.

Convert XML to Image.png

Here's the process that I think the data has undergone:

  • picture data is flattened to a string
  • the data is compressed
  • the length of the original, uncompressed data is prepended to the compressed data
  • the result is 7-bit encoded, so that it's all printable characters -- Basically, the flattened data is converted to an array of bits, then  7-bits at a time, represented as ASCII (which is 8-bits long, but with  the last bit being a zero). 
  • the result is then XML-escaped, so that special xml characters (like "&" and ">") are replaced (with stuff like "&" and ">").

So, we just need to reverse this process, which is what my example attempts (without success) to do.

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

To be clear, in what way does this fail for you? Is the inflation successful, but the result is not the icon? Do you receive an error from the Inflate function? (my problem is currently the latter, error 42)

Chris Bolin
LabVIEW Partner Program, CLA
0 Kudos
Message 13 of 16
(1,064 Views)

Hey Chris,

Yes, I get an error out of the Inflate function -- the data that I've decoded (probably incorrectly) does not seem to be valid z-compressed data .

-Jim

0 Kudos
Message 14 of 16
(1,064 Views)

Jim,

I spent a lot of time today looking at the code we use to write image data to our lvlib files. Since I'm not that familiar with that part of the codebase, it was slow and many things are still confusing. From what I gather, though, these are the steps we follow:

1. Convert icon to pixmap (both color and bw--not sure if these are appended to each other or what).

2. Flatten that data into a byte array.

3. Compress that byte array using ZLib Deflate.

4. Prepend the compressed data with the number of compressed bytes.

5. Prepend the above data with a header (I'm not sure if this is a variable header but in the case I looked at it was 32 bytes long). This header contains information about types/versions that LV uses when decoding the string.

I believe the steps after this (I have not yet verified) are:

1. Convert to 7-bit encoding so that the bytes are human readable.

2. Escape XML.

From what I gather, the only step you seem to be missing is stripping the header for the binary data. Of course, modifying your BD to remove the first 32 elements doesn't fix the Error 42. I'll keep pounding away at it tomorrow and see if I can get some more information.

-Sohum.

Message 15 of 16
(1,064 Views)

Hi Sohum,

Thanks for the details and for your efforts to figure this out.

Yes, it's a bit tricky working with the compressed data, because the encoding is not too obvious (until after it gets decompressed).


Thanks for your continued work and do let me know if there's anything I can do to help

Cheers,

-Jim

0 Kudos
Message 16 of 16
(1,064 Views)