Bitmap coordinates on mouse move or click
I have a need for a viewer that will allow me to shot an image and when in the mouse move event I want to track the actual bitmap pixel coordinate no matter what zoom level or pan position. So I guess I need to translate mouse location to image pixel. Can you do that with your zoom panel?

This is very easy to do.

Check out the Painter sample that comes with ZoomPanel.

Here user can draw lines on a Canvas named PaintCanvas.
On PaintCanvas's left mouse down event handler the coordinates of the mouse on the PaintCanvas are get with:
private void PaintCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        Point startPoint;

        startPoint = e.GetPosition(PaintCanvas);

The startPoint is the actual point on the canvas - the same point/pixel will always have the same coordinates regardless of the applied zoom and panning.

Forum Jump:

Users browsing this thread:
1 Guest(s)