impr: Allow image visualizer image to be scaled
This commit is contained in:
parent
ceed8c7420
commit
6a667d9493
@ -87,15 +87,25 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static ImGui::Texture texture;
|
||||
static float scale = 1.0F;
|
||||
if (shouldReset) {
|
||||
auto pattern = arguments[0].toPattern();
|
||||
|
||||
auto data = pattern->getBytes();
|
||||
texture = ImGui::Texture(data.data(), data.size());
|
||||
scale = 200_scaled / texture.getSize().x;
|
||||
}
|
||||
|
||||
if (texture.isValid())
|
||||
ImGui::Image(texture, texture.getSize());
|
||||
ImGui::Image(texture, texture.getSize() * scale);
|
||||
|
||||
if (ImGui::IsWindowHovered()) {
|
||||
auto scrollDelta = ImGui::GetIO().MouseWheel;
|
||||
if (scrollDelta != 0.0F) {
|
||||
scale += scrollDelta * 0.1F;
|
||||
scale = std::clamp(scale, 0.1F, 10.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
|
Loading…
Reference in New Issue
Block a user