WinAPI是否支持24位+图像?我想使用24位图标(更多定义)作为工具栏按钮图像。我加载了这样的图标:
// 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 );
加载时图像似乎转换为16位...如何在按钮上使用高分辨率图像?
答案 0 :(得分:4)
答案 1 :(得分:2)
Windows图像列表确实支持24位颜色,以及更多格式。您需要在传递给ImageList_Create
的标记中指定颜色格式。对于24位颜色,您需要包含ILC_COLOR24
标志。这些标记记录在此处:http://msdn.microsoft.com/en-us/library/windows/desktop/bb775232.aspx
答案 2 :(得分:1)
问题解决了...对于在调用ImageList_Create()时关心的人使用ILC_COLOR24或ILC_COLOR32 ......这将告诉系统使用24或32 bpp图像。