native-windows-gui
native-windows-gui copied to clipboard
Use alpha channel in ImageList
I have investigated how to use the alpha channel for icons used in ImageList and could solve it partially. (To remove the black icon edges)
It seems like
ILC_COLOR32has to be set on creation (which it already is)LR_CREATEDIBSECTIONhas to be set when callingLoadImageImageList_AddMaskedshould be replaced withImageList_Add
I have tried setting LR_CREATEDIBSECTION and the alpha channel of BMPs works, PNGs will have a black background and ICOs will work sometimes (love.ico works all other .ico do not)
Maybe the DIB section can be created manually?
Otherwise I would suggest adding a function like
native_windows_gui::ImageList.add_bitmap_from_filename_alpha("some_32bit.bmp")
To enable the use of alpha channel icons.
The DIB section is created manually if the "image-decoder" feature is enabled, and it' is always enabled during the tests. See win32::image_decoder::create_bitmap_from_wic.
If possible I'd like to handle all image loading use case in a single function, but if we can', adding a specific function will be ok.
I did not see that the DIB section is already created manually. Could it be that the alpha byte just needs to be set to 255? https://stackoverflow.com/questions/18431902/adding-alpha-channel-to-bitmap-or-converting-bitmap-to-32bit
(Can't test this myself at the moment)