HarmlessDave Posted August 24, 2022 Share Posted August 24, 2022 This code works fine with files created by Paint.Net 4.0.x and the old BMPX export DLL (BMP32 Paint.NET FileType.dll): m_hbm = (HBITMAP)::LoadImage(hInst, MAKEINTRESOURCE(idb_toolbar), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); if (m_hbm == NULL) { DWORD derr = GetLastError(); Logger("toolbar LoadImage error = %d %u %x", derr, derr, derr); } m_ilToolBar = ImageList_Create(bmpw, bmph, ILC_COLOR32, 11, 4); ok2 = ImageList_Add(m_ilToolBar, m_hbm, NULL); If I use 4.3.12 with the same PDN file and save as 32-bit BMP, the ::LoadImage fails with GetLastError() == 183: 11:58:24.266 - toolbar LoadImage error = 183 183 b7 If I look at the old DLL export and the new built-in export, I see that the new version uses a larger header. I can provide samples of both if needed. Our use case is creating bitmaps with transparency for Windows UI elements like toolbar buttons. The old Win32 API calls won't read PNG. Quote Link to comment Share on other sites More sharing options...
Solution toe_head2001 Posted August 25, 2022 Solution Share Posted August 25, 2022 In Paint.NET v4.2, many formats (including BMP) were switched over to the newer WIC encoders/decoders. You may need to start using WIC in your application, or re-encode your bitmap files with a different program. Quote (June 9th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
HarmlessDave Posted August 25, 2022 Author Share Posted August 25, 2022 Thanks, that makes sense to avoid maintaining a bunch of codecs when Microsoft has done that for you, but it's a shame that for 32-bit with alpha the results aren't compatible with their own Win32 API call. https://stackoverflow.com/questions/17602548/how-to-covert-iwicbitmapsource-to-hbitmap It looks like it might be possible to get a HBITMAP from a WIC bitmap, though for now it's easier for us to keep using the old BMPX export DLL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.