LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create .ico file from VI icon using .net

Anyone has a better idea?

CreateIcon.png

 

 

George Zou
Download All
0 Kudos
Message 1 of 7
(2,062 Views)

There should be a way to access the actual icon data directly as the icon editor uses that. The proble just will be to massage that into a bitmap of some sorts that is compatible with the .Net API. Or use the Icon library file somewhere in vi.lib. It constructs an icon file itself which isn’t that complicated since the iCO format is relatively simple. But the NI solution only creates 16x16 and 32x32 icons in standard 16 and 256 color depth. It could be expanded to siupport more but that starts to really turn into some serious work, not because the format is very complex but because dealing with bifmap data is always a bit laborous and in an ICO file you end up having potentially a dozen or more of them,

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 7
(2,047 Views)

I would do it like this:

 

1# extract the .vi's icon via "C:\Program Files\National Instruments\LabVIEW 2020\vi.lib\LabVIEW Icon API"

2# save the extracted labview image to disk as .bmp

3# read the generated .bmp from disk to a dotnet bmp referrence

4# use the dotnet snippet from your original post to create a .ico

 

 

icon-bmp-ico.png

 

 

Message 3 of 7
(1,994 Views)

Thanks for reply, guys.

I'm focusing on the create .ico part with .net.

I know how to do it with gdi or gdi+.  Just try to explorer the .net methods.

 

To my surprise,  .net icon class doesn't work well.

 

By the way, NI icon lib can not write to a .ico file, and using the clipboard should be faster than write to file in general.

I leave the get LabVIEW icon part to the caller.

 

George Zou
0 Kudos
Message 4 of 7
(1,982 Views)

I have to admit, when I tried to run your original .vi,  no .ico file was generated.

 

This was due to "Clipboard:Contains image" always returned false after execution - although I didn't change anything in the sub.vi

but I looked at the .vi properties you pointed out in the sub.vi's comment ...

 

 

 


@zou wrote:

 

I know how to do it with gdi or gdi+


could you describe gdi in this context? like a windows desktop app e.g. gimp or irfanview to generate .ico files?

0 Kudos
Message 5 of 7
(1,965 Views)

I downloaded the SubVI from NI:

https://forums.ni.com/t5/Example-Code/Export-A-Screenshot-Of-A-Graph-Chart-Front-Panel-To-The/ta-p/3...

 

Don't know why it doesn't work on your computer.

 

gdi lib is one of the most important lib on Windows.  It provides graphic functions.

LabVIEW picture function was built based on it.

gdi+ to gdi is like DAQmx to the legacy DAQ.

 

The powerful .NET framework doesn't have a decent icon class.  that's weird.

 

George Zou
Message 6 of 7
(1,953 Views)

 

@zou wrote:

 

The powerful .NET framework doesn't have a decent icon class.  that's weird.Who needs icons? 

Who needs icons?


Ohhh wait, new icon suits are usually one of the most distinguishing items on the feature list for new Windows versions, similar to what NI did somewhere around LabVIEW 2016 or so. 😀

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 7
(1,944 Views)