Reputation: 809
Does the WinAPI support 24bit+ images? I would like to use 24bit icons( more definition ) as toolbar button images. I've loaded the icon's like this:
// create toolbar
HWND hTool = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
m_hWnd[ AUXILIARY_VIEWPORT ], ( HMENU )IDC_TEX_TOOL, GetModuleHandle( NULL ), NULL );
// Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility.
SendMessage( hTool, TB_BUTTONSTRUCTSIZE, ( WPARAM )sizeof( TBBUTTON ), 0 );
SendMessage( hTool, TB_SETBUTTONSIZE, 0, MAKELPARAM( 32, 32 ) );
SendMessage( hTool, TB_SETBITMAPSIZE, 0, MAKELPARAM( 32, 32 ) );
// declare button and bitmap structs
TBBUTTON tbb[ 19 ];
TBADDBITMAP tbab;
HICON hIcon = ( HICON )LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( IDI_GRADIENT ) );
// create and add imagelist
HIMAGELIST hImgList = ImageList_Create( 32, 32, ILC_MASK, 1, 1 );
int nR = ImageList_AddIcon( hImgList, hIcon );
SendMessage( hTool, TB_SETIMAGELIST, 0, ( LPARAM )hImgList);
ZeroMemory( tbb, sizeof( tbb ) );
tbb[ 0 ].iBitmap = 0;
tbb[ 0 ].fsState = TBSTATE_ENABLED;
tbb[ 0 ].fsStyle = BTNS_CHECK;
tbb[ 0 ].idCommand = IDM_EDITTEXTURE_ENABLE;
...
SendMessage( hTool, TB_ADDBUTTONS, SIZEARRAY( tbb ), ( LPARAM )&tbb );
The images seem to be converted to 16bit when loaded...How can I use high res images on buttons?
Upvotes: 2
Views: 2444
Reputation: 50667
Check out here to get the full-featured 24-bit color toolbar. It also contains a demo solution there.
Main idea is to use:
static const UINT kToolBarBitDepth (ILC_COLOR24);
Upvotes: 4
Reputation: 809
Problem solved...for anyone who cares when calling ImageList_Create() use ILC_COLOR24 or ILC_COLOR32...this will tell the system to use 24 or 32 bpp images.
Upvotes: 1
Reputation: 612964
Windows image lists do indeed support 24 bit color, and many more formats. You need to specify the color format in the flags you pass to ImageList_Create
. For 24 bit color, you need to include the ILC_COLOR24
flag. The flags are documented here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775232.aspx
Upvotes: 2