I have been playing around with the SkiaSharpFormsDemos and implemented the Basics bitmap rendering and touch recognisers on my project. What I can't figure out now is, after the bitmap has been panned or scaled and when a touch is made, translate the X,Y coordinates of the touch to the actual X,Y coordinates on the bitmap.
After reading about it more, I have found that you should be able to "reverse" the pan and scale done to the bitmap by using the Matrix.TransX-Y and Matrix.ScaleX-Y and with the touch coordinates to get the actual bitmap coordinates like so:
double bitmapX = (touchPoint.X - bitmap.Matrix.TransX) / bitmap.Matrix.ScaleX; double bitmapY = (touchPoint.Y - bitmap.Matrix.TransY) / bitmap.Matrix.ScaleY;
But the points I get are way off when I am comparing it to the original bitmap. Is there something I am misunderstanding?
My goal is to capture double touches on the bitmap (done!) and then paint a marker on the bitmap where the double touch was made (not done!). The marker must stay put even after the bitmap was panned or scaled so I need to know where to draw on the bitmap. The bitmaps can be large images that wont fit most screens so the need for panning and scaling.