fix: Texture loading from romfs

This commit is contained in:
WerWolv
2023-08-26 23:43:35 +02:00
parent 32e05cc62f
commit 550392c8d6
6 changed files with 10 additions and 15 deletions

View File

@@ -527,10 +527,7 @@ namespace hex::plugin::builtin {
static std::mutex addressMutex;
static TaskHolder addressTask;
static auto mapTexture = [] {
auto image = romfs::get("assets/common/map.jpg");
return ImGui::Texture(reinterpret_cast<const ImU8 *>(image.data()), image.size());
}();
static auto mapTexture = ImGui::Texture(romfs::get("assets/common/map.jpg").span());
static ImVec2 mapSize = scaled(ImVec2(500, 500 / mapTexture.getAspectRatio()));
if (shouldReset) {

View File

@@ -33,8 +33,6 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.menu.help.ask_for_help" }, 4000, CTRLCMD + SHIFT + Keys::D, [] {
PopupDocsQuestion::open();
});
this->m_logoTexture = ImGui::Texture(romfs::get("assets/common/logo.png").span());
}
static void link(const std::string &name, const std::string &author, const std::string &url) {
@@ -63,6 +61,9 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
// Draw the ImHex icon
if (!this->m_logoTexture.isValid())
this->m_logoTexture = ImGui::Texture(romfs::get("assets/common/logo.png").span());
ImGui::Image(this->m_logoTexture, scaled({ 64, 64 }));
ImGui::TableNextColumn();

View File

@@ -422,9 +422,7 @@ namespace hex::plugin::builtin {
(void)EventManager::subscribe<RequestChangeTheme>([](const std::string &theme) {
auto changeTexture = [&](const std::string &path) {
auto textureData = romfs::get(path);
return ImGui::Texture(reinterpret_cast<const ImU8*>(textureData.data()), textureData.size());
return ImGui::Texture(romfs::get(path).span());
};
ThemeManager::changeTheme(theme);