2017-07-26 108 views
0

使用位图我有一个使用位图图像的工具栏。我使用示例文件中的通用位图,他们工作得很好。从资源文件

然而,当我尝试添加一个新的位图图标,这种情况下它的close.bmp(它也是正确的大小16x15像素,就像所有其他的图标)我的程序给我的错误。

我只需要知道如何使用位图从资源文件

错误

../../src/msw/toolbar.cpp(799): assert "Assert Failure" failed in 
Realize():invalid tool button bitmap 

Cant load bitmap 'close' from resources! Check.rc file. 

资源.RC

new BITMAP "bitmaps/new.bmp" 
open BITMAP "bitmaps/open.bmp" 
save BITMAP "bitmaps/save.bmp" 
help BITMAP "bitmaps/help.bmp" 
close BITMAP "bitmaps/close.bmp" 

的.cpp

{ 
    // Set up toolbar 
    enum 
    { 
     Tool_new, 
     Tool_open, 
     Tool_save, 
     Tool_help, 
     Tool_close, 
     Tool_Max 
    }; 

    wxBitmap toolBarBitmaps[Tool_Max]; 

#if USE_XPM_BITMAPS 
    #define INIT_TOOL_BMP(bmp) \ 
     toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm) 
#else // !USE_XPM_BITMAPS 
    #define INIT_TOOL_BMP(bmp) \ 
     toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp) 
#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS 



    INIT_TOOL_BMP(new); 
    INIT_TOOL_BMP(open); 
    INIT_TOOL_BMP(save); 
    INIT_TOOL_BMP(help); 
    INIT_TOOL_BMP(close); 

    toolBar->AddTool(wxID_ANY, wxT("New"), toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL, wxT("New IWEX Project")); 
    toolBar->AddTool(wxID_ANY, wxT("Open"), toolBarBitmaps[Tool_open], wxNullBitmap,wxITEM_NORMAL , wxT("Open IWEX Project")); 
    toolBar->AddTool(idFileClose, wxT("Close"), toolBarBitmaps[Tool_close], wxT("Close button"), wxITEM_NORMAL); 

    toolBar->Realize(); 

} 
+0

奇怪。哪个wxWidgets版本?为了找出问题的原因是位图,复制一个工作位图(例如“new.bmp”)并重命名它(“close.bmp”)。 – Ripi2

+0

@MaazAzeem,你叫InitAllImageHandlers()吗? – Igor

回答

0

所以我能够解决这个问题。代码似乎不是一个问题。它是位图文件格式。我不完全确定为什么它有所作为,但我从GIMP编辑照片尺寸,我会得到问题。如果我使用FastStone图像查看器调整大小,它看起来是正确的。