简体   繁体   中英

Bitmap coordinates after canvas.scale

I need help at getting the correct coordinates when touching the canvas.

I have an image that is 1240x1756

The user can scroll around on this bitmap. It is the bitmap attached to the canvas. I do this by translating the canvas. canvas.translate()

The user can also place a new bitmap and move that anywhere around on the canvas. up to 256x256.

Up until this point I have no problem calculating the touch coordinates at scale factor of 1.0. I take the screen touch coords and add the offset of the image and then check to see if the 256x256 moveable bitmap intersects the touch coords.

However my issue is getting the correct coordinates after the canvas has been scaled. 0.1-1.0 are my minimum and maximum scaling values.

Can anyone point me in the right direction for a working algorithm?

您应该能够将像素偏移乘以1 /比例因子。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM