Skip to content

Commit

Permalink
#6178: Loading bitmaps through wxBitmap::LoadFile is not working in W…
Browse files Browse the repository at this point in the history
…indows, it's always sticking to the BMP handler it seems.
  • Loading branch information
codereader committed Dec 26, 2022
1 parent 51c3bd6 commit d0af9d2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions radiant/RadiantApp.cpp
Expand Up @@ -63,24 +63,28 @@ class RadiantApp::ArtProvider final: public wxArtProvider
wxArtProvider::Push(this);
}

wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size)
wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size) override
{
auto filename = id.ToStdString();
const auto& prefix = ArtIdPrefix();

// We listen only to "darkradiant" art IDs
if (string::starts_with(filename, prefix))
{
std::string filePath = _searchPath + filename.substr(prefix.length());
auto filePath = _searchPath + filename.substr(prefix.length());

if (os::fileOrDirExists(filePath)) {
if (os::fileOrDirExists(filePath))
{
#ifdef __WXMSW__
return wxBitmap(wxImage(filePath));
#else
wxBitmap bm;
if (bm.LoadFile(filePath)) {
return bm;
}
else {
rError() << "Failed to load bitmap [" << filePath << "]\n";
}

rError() << "Failed to load bitmap [" << filePath << "]\n";
#endif
}
}

Expand Down

0 comments on commit d0af9d2

Please sign in to comment.