HarmlessDave Posted August 24, 2022 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
Solution toe_head2001 Posted August 25, 2022 Solution 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 My Gallery | My Plugin Pack Layman's Guide to CodeLab
HarmlessDave Posted August 25, 2022 Author 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
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.