08-03-2022 07:07 PM
Anyone has a better idea?
08-03-2022 08:04 PM
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,
08-04-2022 07:29 AM - edited 08-04-2022 07:30 AM
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
08-04-2022 09:02 AM
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.
08-04-2022 02:35 PM
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?
08-04-2022 04:12 PM
I downloaded the SubVI from NI:
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.
08-04-2022 05:27 PM - edited 08-04-2022 05:30 PM
@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. 😀