fix(wsi): correct point annotation placement on SM/WSI viewports at n…#2769
Merged
sedghi merged 3 commits intoJul 8, 2026
Merged
Conversation
…on-default devicePixelRatioPatch @cornerstonejs/core WSIViewport to stop scaling canvas coordinates bydevicePixelRatio in canvasToIndex/indexToCanvas. WSIViewport sizes its canvasin CSS pixels and its transform works in CSS-pixel space, so the extra DPR
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesWSIViewport Coordinate Conversion
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
sedghi
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Fixes WSIViewport annotation placement on HiDPI (Retina/high-DPI) displays.
WSIViewportsizes its canvas in CSS pixels and its internal transform (getTransform()) already operates in CSS-pixel space. ThecanvasToIndexmethod was pre-multiplyingcanvasPosbydevicePixelRatiobefore transforming, andindexToCanvaswas post-dividing bydevicePixelRatioafter transforming. On displays wheredevicePixelRatio > 1, this caused annotations to be placed at incorrect positions because the DPR scaling was applied twice.Changes & Results
canvasToIndex: RemovedcanvasPos.map((it) => it * devicePixelRatio)— passcanvasPosdirectly totransformPoint.indexToCanvas: Removed.map((it) => it / devicePixelRatio)— returntransformPointresult directly.Before: Annotations on WSI images are offset/misaligned on HiDPI screens (
devicePixelRatio > 1).After: Annotations render at the correct positions on all displays. No behavior change on standard displays where
devicePixelRatio === 1.Testing
WSIViewport.devicePixelRatio > 1), place an annotation (e.g. length or area tool).Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment
Summary by CodeRabbit