Get the center of visible part of a transformed image

F Scheltens

F Scheltens

Jan 13 2017 5:51 PM
i have made a control that zooms an image in and out, using an example i found online as a basis. It is a class which is subclassed from Border and applies transforms to its child. It zooms and pans its child by applying a RenderScaleTransform for zooming in and out, and a RenderTranslateTransform for panning. 
When using the mouse this works really well. But when I use a keyboard I am unable to make it zoom in and out with the center of the visible part of the image as origin.

How do I correctly calculate the coordinates that are the middle of the visible part of the image?
I have attached the project folders to this post. The zoomborder is in a library. Project with a client and example image is included. (Solution file is in the Zoomborder folder)

Answers (1)