Jump to content
  • Advertisement
Sign in to follow this  
Syndication

[C++] Transparent toolbar bitmap.

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm using VS [C++] 2008 Express (no MFC). I've been trying all day to get a toolbar onto my app that uses a .bmp file for the icons. The code I've used to do this is: // Load toolbar bitmap. (48 pixel wide, 16 high) HBITMAP hbmTool = (HBITMAP)LoadImage(g_mainhInstance, "tool.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS); // blah blah, setup buttons.. HWND hWnd = CreateToolbarEx(g_mainWinHandle, WS_CHILD | WS_VISIBLE, IDTB_MAIN, 3, NULL, (UINT)hbmTool, tbButtons, 3, 16, 16, 16, 16, sizeof(TBBUTTON)); This works OK, but for the fact that the background part of the tool.bmp that is supposed to be transparent is showing as white. I've literally been googling this problem all day trying to find out how I resolve this to the point I now have a headache. X( I realise I need to be using TransparentBlt and/or BitBlt. I had no luck with TransparentBlt, but this is as far as I've got using BitBlt: HBITMAP hbmTool = (HBITMAP)LoadImage(g_mainhInstance, "tool2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS); HDC hdcTool, hdcNew; hdcTool = CreateCompatibleDC(0); SelectBitmap(hdcTool, hbmTool); HBITMAP hbmNew = CreateBitmap(48, 16, 1, 1, NULL); hdcNew = CreateCompatibleDC(0); SelectBitmap(hdcNew, hbmNew); SetBkColor(hdcTool, (COLORREF)RGB(130, 255, 255)); // This is the background color of the tool.bmp BitBlt(hdcNew, 0, 0, 48, 16, hdcTool, 0, 0, SRCCOPY); // .. tidy up etc So I have a HDC/HBITMAT to a 1 bit bitmap that is a black mask of the actual 'icons' in tool2.bmp, and the background of it is now transparent, but I can't find or understand the process of printing the color of the 'icons' in the tool.bmp to a final HBITMAP using this mask. I've read every resource I can find on the net but I can't make sense of this final stage. This has become a brickwall in my learning project, I'd HUGELY appreciate any one who can take a moment out and reveal (and briefly explain if possible) this last step to me.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!