DodoSombrero
DodoSombrero

Reputation: 777

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?

Upvotes: 0

Views: 2551

Answers (2)

VZ.
VZ.

Reputation: 22688

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.

Upvotes: 1

VZ.
VZ.

Reputation: 22688

If I understand your question correctly, you should find wxStandardPaths class useful. In particular, images used in the program are typically loaded from the directory returned by its GetResourcesDir() method.

Upvotes: 1

Related Questions