简体   繁体   中英

..msw\bitmap.cpp(842): assert ""image.IsOk()"" failed in wxBitMap::CreateFromImage(): invalid image [C++][wxWidgets 3.1.3]

The following code compiles and runs fine under Linux:

https://i.postimg.cc/B6PPn01C/Screenshot-20200320-184650.png

staticboxsizer_Logo = new wxStaticBoxSizer(wxHORIZONTAL, Panel1, wxEmptyString);
    staticbitmap_logo = new wxStaticBitmap(Panel1, ID_STATICBITMAP2, wxBitmap(wxImage(_T("C:\Logo_0.png"))), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICBITMAP2"));
    staticboxsizer_Logo->Add(staticbitmap_logo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);[/code]

Under Windows it compiles fine too, however when I run the .exe I get the following error:

C:\wxWidgets\src\msw\bitmap.cpp(842): assert ""image.IsOk()"" failed in wxBitMap::CreateFromImage(): invalid image

What can I do so the logo (265x46 px) also shows fine under Windows?

Thanks

You need to use a valid file path.

"/mnt/data/VMware/VM-Shared/Logo_0.png" is not a valid path under Windows .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM