checking-image-bounds-transform

Solid

Checks and clamps mouse coordinates within transformed image bounds in WPF. Use when implementing measurement tools or annotations that should only work inside Pan/Zoom/Rotate transformed images.

Data & Documents 35 stars 4 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 77/100

Stars 20%
52
Recency 20%
100
Frontmatter 20%
40
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# WPF Image Bounds Checking (With Transforms) A pattern for checking if mouse coordinates are within the image area and clamping coordinates to image bounds when Pan, Zoom, Rotate transforms are applied. ## 1. Problem Scenario ### Requirements - Measurement tools, annotation tools in image viewers should only work **within the image area** - Need accurate boundary detection even when image is zoomed, panned, or rotated ### Complexity - `Image` control position varies based on `Stretch="None"`, `HorizontalAlignment="Center"` settings - When `RenderTransform` applies Pan, Zoom, Rotate, calculating actual image position becomes complex --- ## 2. Solution Pattern ### 2.1 Image Bounds Check Method ```csharp namespace MyApp.Controls; using System.Windows; using System.Windows.Controls; using System.Windows.Media; public class ImageViewer : Control { // DependencyProperties (omitted) public ImageSource? ImageSource { get; set; } public double ZoomFactor { get; set; } = 1.0; public double PanX { get; set; } public double PanY { get; set; } public double RotationAngle { get; set; } /// <summary> /// Check if the given point is within the image area. /// </summary> /// <param name="point">Point in parent container coordinates</param> /// <returns>True if within image area</returns> public bool IsPointWithinImage(Point point) { if (ImageSource is null) return false; // 1. Original image size ...

Details

Author
christian289
Repository
christian289/dotnet-with-claudecode
Created
5 months ago
Last Updated
3 days ago
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

image-crop-rotate

Image processing skill for cropping images to 50% from center and rotating them 90 degrees clockwise. This skill should be used when users request image cropping to center, image rotation, or both operations combined on image files.

832 Updated 1 weeks ago
instavm
Web & Frontend Solid

clearshot

Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.

129 Updated 2 months ago
udayanwalvekar
Testing & QA Featured

browser-testing-with-devtools

Tests in real browsers. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data via Chrome DevTools MCP.

45,628 Updated yesterday
addyosmani
Data & Documents Featured

pdf-page-verification-correction

Iterative workflow to verify PDF page counts and adjust layout parameters until requirements are met

6,332 Updated 4 days ago
HKUDS
AI & Automation Solid

cross-page-analyzer

Internal helper for cross-page accessibility pattern detection, severity scoring, and scorecard generation. Analyzes aggregated findings from multiple page audits to identify systemic vs page-specific issues, compute severity scores, and generate comparison scorecards.

283 Updated 2 days ago
Community-Access