我已经尝试了几天在wxWidgets对话框中从内存中显示BMP图像,但是我的所有尝试都失败了。
首先,我尝试在对话框中创建一个wxStaticBitmap控件:
我没有收到错误信息,但是图片没有显示出来。其次,我尝试在对话框的EVT_PAINT事件中绘制这张图片:
现在我收到了这个调试警告: http://img266.imageshack.us/img266/9512/wxerror.jpg 调试器停在了这一行:
请问有人能指引我吗?
首先,我尝试在对话框中创建一个wxStaticBitmap控件:
// in class declaration inside header file
wxStaticBitmap *ibitmap;
// in wxDialog constructor
// MyLogo is an array of `unsigned char`
// contains the bitmap file (Yes, the bitmap file, with BMP header)
ibitmap = new wxStaticBitmap(mainPanel, 4000, wxBitmap(MyLogo, wxBITMAP_TYPE_BMP, 200, 62), wxPoint(10, 10), wxSize(200, 62));
我没有收到错误信息,但是图片没有显示出来。其次,我尝试在对话框的EVT_PAINT事件中绘制这张图片:
// in the class declaration inside header file
wxBitmap *ibitmap;
// in the events declaration
EVT_PAINT(OnPaint)
// in wxDialog constructor
ibitmap = new wxBitmap(MyLogo, wxBITMAP_TYPE_BMP, 200, 62);
// event method implementation
void MyDialog::OnPaint(wxPaintEvent &event)
{
wxPaintDC dc(this);
dc.DrawBitmap(*ibitmap, 10, 10);
}
现在我收到了这个调试警告: http://img266.imageshack.us/img266/9512/wxerror.jpg 调试器停在了这一行:
// dc.h Ln 271
{ DoDrawBitmap(bmp, x, y, useMask); }
请问有人能指引我吗?
dc.DrawBitmap
断言bmp.Ok()
,这意味着无论dc.DrawBitmap
被要求绘制的位图是什么,都不是OK的。 - heavyd