impr: Add support for specifying filtering mode when loading textures

This commit is contained in:
WerWolv
2023-12-09 22:00:35 +01:00
parent e49c3182ce
commit ef7898ea8d
12 changed files with 54 additions and 33 deletions

View File

@@ -286,7 +286,7 @@ namespace hex::plugin::builtin {
void process() override {
const auto &rawData = this->getBufferOnInput(0);
this->m_texture = ImGuiExt::Texture(rawData.data(), rawData.size());
this->m_texture = ImGuiExt::Texture(rawData.data(), rawData.size(), ImGuiExt::Texture::Filter::Nearest);
}
private:
@@ -317,7 +317,7 @@ namespace hex::plugin::builtin {
if (requiredBytes > rawData.size())
throwNodeError(hex::format("Image requires at least {} bytes of data, but only {} bytes are available", requiredBytes, rawData.size()));
this->m_texture = ImGuiExt::Texture(rawData.data(), rawData.size(), width, height);
this->m_texture = ImGuiExt::Texture(rawData.data(), rawData.size(), ImGuiExt::Texture::Filter::Nearest, width, height);
}
private:

View File

@@ -783,7 +783,7 @@ namespace hex::plugin::builtin {
vertexArray.bind();
if (s_shouldUpdateTexture) {
s_shouldUpdateTexture = false;
s_modelTexture = ImGuiExt::Texture(s_texturePath);
s_modelTexture = ImGuiExt::Texture(s_texturePath, ImGuiExt::Texture::Filter::Nearest);
}
if (s_drawTexture)

View File

@@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
static std::mutex addressMutex;
static TaskHolder addressTask;
static auto mapTexture = ImGuiExt::Texture(romfs::get("assets/common/map.jpg").span());
static auto mapTexture = ImGuiExt::Texture(romfs::get("assets/common/map.jpg").span(), ImGuiExt::Texture::Filter::Linear);
static ImVec2 mapSize = scaled(ImVec2(500, 500 / mapTexture.getAspectRatio()));
if (shouldReset) {

View File

@@ -17,7 +17,7 @@ namespace hex::plugin::builtin {
auto pattern = arguments[0].toPattern();
auto data = pattern->getBytes();
texture = ImGuiExt::Texture(data.data(), data.size());
texture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest);
scale = 200_scaled / texture.getSize().x;
}
@@ -43,7 +43,7 @@ namespace hex::plugin::builtin {
auto height = arguments[2].toUnsigned();
auto data = pattern->getBytes();
texture = ImGuiExt::Texture(data.data(), data.size(), width, height);
texture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Nearest, width, height);
}
if (texture.isValid())

View File

@@ -163,7 +163,7 @@ namespace hex::plugin::builtin {
for (auto &pixel : pixels)
pixel = (pixel & 0xFF00FF00) | ((pixel & 0xFF) << 16) | ((pixel & 0xFF0000) >> 16);
texture = ImGuiExt::Texture(reinterpret_cast<const u8*>(pixels.data()), pixels.size(), bitmap.bmWidth, bitmap.bmHeight);
texture = ImGuiExt::Texture(reinterpret_cast<const u8*>(pixels.data()), pixels.size(), ImGuiExt::Texture::Filter::Nearest, bitmap.bmWidth, bitmap.bmHeight);
}
}
}

View File

@@ -45,7 +45,7 @@ namespace hex::plugin::builtin {
// Draw the ImHex icon
if (!this->m_logoTexture.isValid())
this->m_logoTexture = ImGuiExt::Texture(romfs::get("assets/common/logo.png").span());
this->m_logoTexture = ImGuiExt::Texture(romfs::get("assets/common/logo.png").span(), ImGuiExt::Texture::Filter::Linear);
ImGui::Image(this->m_logoTexture, scaled({ 100, 100 }));
if (ImGui::IsItemHovered() && ImGui::IsItemClicked()) {
@@ -116,9 +116,9 @@ namespace hex::plugin::builtin {
};
static std::array DonationPages = {
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/paypal.png").span<std::byte>()), "https://werwolv.net/donate" },
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/github.png").span<std::byte>()), "https://github.com/sponsors/WerWolv" },
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/patreon.png").span<std::byte>()), "https://patreon.com/werwolv" },
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/paypal.png").span<std::byte>(), ImGuiExt::Texture::Filter::Linear), "https://werwolv.net/donate" },
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/github.png").span<std::byte>(), ImGuiExt::Texture::Filter::Linear), "https://github.com/sponsors/WerWolv" },
DonationPage { ImGuiExt::Texture(romfs::get("assets/common/donation/patreon.png").span<std::byte>(), ImGuiExt::Texture::Filter::Linear), "https://patreon.com/werwolv" },
};
ImGui::NewLine();

View File

@@ -513,7 +513,7 @@ namespace hex::plugin::builtin {
(void)RequestChangeTheme::subscribe([](const std::string &theme) {
auto changeTexture = [&](const std::string &path) {
return ImGuiExt::Texture(romfs::get(path).span());
return ImGuiExt::Texture(romfs::get(path).span(), ImGuiExt::Texture::Filter::Linear);
};
ThemeManager::changeTheme(theme);
@@ -639,7 +639,7 @@ namespace hex::plugin::builtin {
for (const auto &defaultPath : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
const auto infoBannerPath = defaultPath / "info_banner.png";
if (wolv::io::fs::exists(infoBannerPath)) {
s_infoBannerTexture = ImGuiExt::Texture(wolv::util::toUTF8String(infoBannerPath).c_str());
s_infoBannerTexture = ImGuiExt::Texture(wolv::util::toUTF8String(infoBannerPath).c_str(), ImGuiExt::Texture::Filter::Linear);
if (s_infoBannerTexture.isValid())
break;
@@ -656,7 +656,7 @@ namespace hex::plugin::builtin {
if (response.isSuccess()) {
const auto &data = response.getData();
TaskManager::doLater([data] {
s_infoBannerTexture = ImGuiExt::Texture(data.data(), data.size());
s_infoBannerTexture = ImGuiExt::Texture(data.data(), data.size(), ImGuiExt::Texture::Filter::Linear);
});
}
});