Skip to content

[minor] Add PixelLoupe, a magnified pixel readout beside an ImageCanvas - #574

Merged
matt-edmondson merged 3 commits into
mainfrom
widget/stack-loupe
Sep 30, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
widget/stack-loupe

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: an ImageCanvas gave no way to inspect the exact value of the pixel under the pointer.

After: while the pointer is over an ImageCanvas, ImGuiWidgets.PixelLoupe draws a magnified grid of the surrounding pixels. It outlines the centre pixel, marks the same pixel on the canvas, and reads it out as coordinates, RGBA and hex. Pixels come from a callback the caller supplies, so nothing is read back from the GPU. The loupe takes no input, so the canvas keeps its own pan and zoom.

How: PixelLoupeState holds the hover and clamping rules and has no ImGui dependency. ImageCanvasState.ImageToViewport is the same inverse mapping the CropOverlay PR adds, so it appears only once in the stack. The gallery's SampleImage exposes PixelAt, so the loupe tile reads the same pixels the texture holds. The PR adds a demo section, an isolation suite, a gallery tile and docs entries.

Stacked PR. The base is #573 (CropOverlay), and this is the top of the image-widget stack. Merge order: #570 → #571 → #572 → #573 → this.

Validation, Release build: the solution builds clean, and ImGuiWidgetsDemo.UITests passes 46/46. On this top branch, ImGui.Widgets.Tests passes 931/931, ImGui.Widgets.UITests 629/629 and WidgetGallery.UITests 6/6, and WidgetGallery --check passes.

Closes #529

🤖 Generated with Claude Code

https://claude.ai/code/session_01LXUsRiHnKs6HCgLAbC1L6D


Generated by Claude Code

ImGuiWidgets.PixelLoupe draws a grid of the pixels around the pointer while it
is over an ImageCanvas, outlines the centre pixel, and reads it out as
coordinates, RGBA and hex. It also marks that pixel on the canvas. Pixels come
from a caller-supplied callback, so no texture is read back, and the loupe
takes no input, so the canvas keeps its pan and zoom. PixelLoupeState holds the
hover and clamping rules with no ImGui dependency.

ImageCanvasState gains ImageToViewport, the inverse of ViewportToImage. The
gallery's SampleImage exposes PixelAt so the loupe tile reads the same pixels
the texture holds.

Closes #529

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXUsRiHnKs6HCgLAbC1L6D
@matt-edmondson matt-edmondson self-assigned this Sep 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain widgets Tier 3: add PixelLoupe (magnified pixel grid with RGBA readout over ImageCanvas)

2 participants