Jump to content

BMP 32-bit alpha files not compatible with win32 LoadImage()


Go to solution Solved by toe_head2001,

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...