3
我試圖在wxWidgets對話框中顯示內存中的BMP圖像,但我的嘗試都沒有成功。在wxWidgets中顯示靜態圖像?
首先,我想在我的對話框創建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); }
任何人請指出我?
我100%確定圖像是一個有效的24位位圖轉換成字節數組。 – 2010-05-19 06:37:42
** 100%** ??在錯誤對話框中,顯示調用'dc.DrawBitmap'在'bmp.Ok()'上聲明,這意味着要求繪製任何位圖'dc.DrawBitmap',而不是** OK。 – heavyd 2010-05-19 10:48:59
@djzmo:如果有疑問,請使用調試器瀏覽wxWidgets代碼。我發現了許多使用此方法的未記錄異常(例如wxDbTable中的未記錄項目)。 – 2010-05-19 16:21:03