My thoughts about using Windows API in apps.
This note is for future me (or someone who wants to help with IcoApp code).
Last week I was busy rewriting IcoApp from scratch. Yes, this looks like my favorite hobby. In the previous version I used my own ico file deserialization code. Not only the ico directory, but bitmaps were parsed by my code. I even extracted some PNG metadata myself. That was fine for learning, but in practice there are some small problems. If I continue doing that, I will end up with a full featured library just for ico file extraction. That would be too much for a simple app.
In the new version I almost made the same mistake again. But after one day I realized that writing a parser for a Windows-only app is overkill. So I deleted all the parsing code. Good news — the tests survived! I already wrote an article about ico file extraction with Win32 API. That approach works well for Windows apps. I will leave cross-platform code for myself in the future (in case I decide to port the app to Avalonia).
So for now, ico file parsing is done with Win32 API and System.Drawing.Common. The ico file generation code is simpler because I don’t support all formats. Only 32-bit bitmaps and PNG images are supported. That means I can still play with bytes and write the generation code from scratch without using the existing API.
Happy coding!