cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

Added support for setting arbitrary-format icons on Windows #658

Closed ventsin closed 6 months ago

ventsin commented 2 years ago

Currently on the Windows platform, window icons must either be a .ico file, a ICO encoded buffer or a resource icon.

To me, this doesn't make much sense, as the Win32 API easily supports creating icons on the fly straight from pixel data.

So in this PR I added support for creating icons directly from the pixel data stored in nana::paint::image. The point of this is that now one can easily set any bmp, png or jpeg (provided png and jpeg are enabled, respectively) as icons as well.

On that note I also wanted to say that the pixel buffer can be quite difficult to get pixel data from. Maybe the API could be improved in that regard.