Skip to content

Commit 45da617

Browse files
committed
improve demo_immvision_display
1 parent 86b77cc commit 45da617

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

bindings/imgui_bundle/demos_cpp/demos_immvision/demo_immvision_display.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "immapp/immapp.h"
22
#include "immvision/immvision.h"
33
#include "demo_utils/api_demos.h"
4+
#include "hello_imgui/hello_imgui.h"
45
#include <opencv2/imgcodecs.hpp>
5-
6+
#include "imgui.h"
67

78
void demo_immvision_display()
89
{
@@ -18,14 +19,30 @@ void demo_immvision_display()
1819
std::string assetsDir = DemosAssetsFolder() + "/images/";
1920
bear = cv::imread(assetsDir + "bear_transparent.png", cv::IMREAD_UNCHANGED);
2021
tennis = cv::imread(assetsDir + "tennis.jpg");
22+
23+
int bearDisplaySize = int(HelloImGui::EmSize(15.f));
24+
params.ImageDisplaySize = cv::Size(bearDisplaySize, bearDisplaySize);
25+
2126
inited = true;
2227
}
2328

24-
ImGuiMd::RenderUnindented("ImmVision::ImageDisplay() will simply display an image");
29+
ImGui::BeginGroup();
30+
ImGuiMd::RenderUnindented("# ImmVision::ImageDisplay()");
31+
ImGuiMd::RenderUnindented("Displays an image (possibly resizable)");
2532
ImmVision::ImageDisplayResizable("Tennis", tennis, &imageDisplaySize);
33+
ImGui::EndGroup();
2634

27-
ImGuiMd::RenderUnindented(R"(
28-
immvision.image() will display an image, while providing lots of visualization options.<br>
29-
Open the options panel by clicking on the settings button at the bottom right corner of the image)");
35+
ImGui::SameLine();
36+
37+
ImGui::BeginGroup();
38+
ImGuiMd::RenderUnindented("# ImmVision::Image()");
39+
ImGuiMd::RenderUnindented("Displays an image, while providing lots of visualization options.");
3040
ImmVision::Image("Bear", bear, &params);
41+
ImGuiMd::RenderUnindented(R"(
42+
* Zoom in/out using the mouse wheel.
43+
* Pixel values are displayed at high zoom levels.
44+
* Pan the image by dragging it with the left mouse button
45+
* Open settings via button (bottom right corner of the image)
46+
)");
47+
ImGui::EndGroup();
3148
}

bindings/imgui_bundle/demos_python/demos_immvision/demo_immvision_display.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from imgui_bundle import immvision, immapp, imgui_md, ImVec2
1+
from imgui_bundle import immvision, immapp, imgui_md, ImVec2, imgui, hello_imgui
22
from imgui_bundle.demos_python import demo_utils
33

44
immvision.use_rgb_color_order()
@@ -16,19 +16,31 @@ def demo_gui() -> None:
1616
statics.tennis = demo_utils.imread_pil(assets_dir + "tennis.jpg")
1717

1818
statics.params = immvision.ImageParams()
19+
bear_display_size = int(hello_imgui.em_size(15))
20+
statics.params.image_display_size = (bear_display_size, bear_display_size)
1921
statics.inited = True
2022

21-
imgui_md.render_unindented("immvision.image_display() will simply display an image")
23+
imgui.begin_group()
24+
imgui_md.render_unindented("# immvision.image_display()")
25+
imgui_md.render_unindented("Displays an image (possibly resizable)")
2226
immvision.image_display_resizable(
2327
"Tennis", statics.tennis, size=statics.image_display_size
2428
)
29+
imgui.end_group()
2530

26-
imgui_md.render_unindented(
27-
"""
28-
immvision.image() will display an image, while providing lots of visualization options.<br>
29-
Open the options panel by clicking on the settings button at the bottom right corner of the image"""
30-
)
31+
imgui.same_line()
32+
33+
imgui.begin_group()
34+
imgui_md.render_unindented("# immvision.image()")
35+
imgui_md.render_unindented("Displays an image, while providing lots of visualization options.")
3136
immvision.image("Bear", statics.bear, statics.params)
37+
imgui_md.render_unindented("""
38+
* Zoom in/out using the mouse wheel.
39+
* Pixel values are displayed at high zoom levels.
40+
* Pan the image by dragging it with the left mouse button
41+
* Open settings via button (bottom right corner of the image)
42+
""")
43+
imgui.end_group()
3244

3345

3446
def main():

0 commit comments

Comments
 (0)