Manipulate origin of PixelCoordinates on WPF Display

Hi Everyone,

triggered by a request of one of our customers I am facing a problem that I am not sure on how to best address.

Given:
WPF DisplayControl

Needed:
Origin of the pixel coordinates of the cursor displayed at the bottom have to start wit 0/0 on the bottom left corner.

My first try would be to manipulate the CoordinateSystem of the underlying Image of the DisplayControl.
As far as I was able to find out this is represented by an AffineMatrix.
This already has a Inverse() implemented but this would not solve our problem as this would move the origin to the bottom right as far as I am aware.

So the solution I came up with would be to use a lib for matrix-manipulation and do a horizontal flip on the Matrix of the image. Then assign the flipped matrix back to the image as the new CoordinateSystem.

Is this valid?
Is there a better way?

Thank you in advance and
Cheers
Chris

Not necessarily… What you basically want to do is invert the direction of the y axis and shift the origin. If the height of you image is h pixels, then

var m = new AffineMatrix2D(new Matrix2D(1.0, 0.0, 0.0, -1.0), new Point2Dd(0.0, h))

should do the trick. At least with the Forms display - I am not entirely certain what the WPF display does regarding the coordinate system.

2 Likes