class mrpt::imgui::CImGuiImageView
Overview
Shows an mrpt::img::CImage in an ImGui panel, as an OpenGL texture.
Mouse wheel zooms at the cursor, dragging pans, double click fits the image to the panel; hovering shows the pixel coordinates and value. The right-click menu offers “Fit”, “1:1” and “Save image as…”.
Gray and color images of 8 bits per channel are shown as they are; 16-bit images are scaled to their own value range for display.
Must be used from the thread owning the GL context.
#include <mrpt/imgui/CImGuiImageView.h> class CImGuiImageView { public: // fields bool autoFit = true; bool showPixelInfo = true; std::function<void()> onContextMenu; // construction CImGuiImageView(); CImGuiImageView(const CImGuiImageView&); // methods CImGuiImageView& operator = (const CImGuiImageView&); void setImage(const mrpt::img::CImage& img); void clear(); bool hasImage() const; const mrpt::img::CImage& image() const; void render(const char* id, float width = 0, float height = 0); ImageViewTransform& transform(); static std::vector<uint8_t> toRGBA8(const mrpt::img::CImage& img); static std::string pixelInfo(const mrpt::img::CImage& img, int u, int v); };
Fields
bool autoFit = true
Keep the image fitted to the panel when the panel is resized, until the user zooms or pans.
bool showPixelInfo = true
Show the pixel coordinates and value under the mouse.
std::function<void()> onContextMenu
Extra items for the right-click menu.
Methods
void setImage(const mrpt::img::CImage& img)
Sets the image to show (uploaded to the GPU on the next render).
void render(const char* id, float width = 0, float height = 0)
Draws the view as a child region of the given size (0: all available space) in the current window.
static std::vector<uint8_t> toRGBA8(const mrpt::img::CImage& img)
Converts an image into the 8-bit RGBA buffer uploaded as texture (rows top to bottom).
Exposed for testing.
static std::string pixelInfo(const mrpt::img::CImage& img, int u, int v)
Text describing the pixel (u,v) of the image (value of each channel), or empty if out of the image.