Search code examples
c++wxwidgets

wxWidgets Load Image from file


I need to load an image, but the moment I only have an absolute path:

StaticBitmap1 = new wxStaticBitmap(this, ID_STATICBITMAP1, wxBitmap(wxImage(_T("C:\\Users\\Jurgen\\Documents\\C++\\Dorienne-COPITRON\\copy_logo.jpg")).Rescale(wxSize(0,72).GetWidth(),wxSize(0,72).GetHeight())), wxPoint(32,24), wxSize(0,72), wxSIMPLE_BORDER, _T("ID_STATICBITMAP1"));

Is there a way to make it relative? instead of simple C:\Users...

Thanks in advance


EDIT: I managed to make it Referencial by just leaving it "copy_logo.jpg" as the path, but I have this error popping every time I run it.

Debug Error Alert

More errors keep on showing if I press NO. I have to press CANCEL all the time. Any idea why?


Solution

  • Your problem is obviously due to using invalid wxSize, exactly as the assert message says (have you read it?). I don't know what are you trying to do here but you can't use wxSize(0, 72). Just call Rescale(72, 72) instead.