Display static image in wxWidgets?

These were the days when I tried to display a BMP image from memory in the wxWidgets dialog box, but none of my attempts succeeded.

First, I tried to create the wxStaticBitmap control in my dialog box:

// 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));

I have no errors, but the image did not appear.

Secondly, I tried to draw an image inside the EVT_PAINT dialog box:

// 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);
}

Now I got this debug warning: http://img266.imageshack.us/img266/9512/wxerror.jpg

and the debugger is stopped at this line:

// dc.h Ln 271
{ DoDrawBitmap(bmp, x, y, useMask); }

Anyone please point me?

+3
source share
1 answer

. wxWidgets docs wxBitmap, , :

 wxBitmap(const char bits[], int width, int height, int depth=1)

, - :

wxBitmap(MyLogo, 200, 62, 3)

RGB.

+1

Source: https://habr.com/ru/post/1746124/


All Articles