Canvas - zooming in, shifting, and scaling on Android

前端 未结 5 987
广开言路
广开言路 2020-12-24 00:34

I\'m currently implementing a draw function on a webview image (the elephant below). I don\'t have a problem drawing on it but the zoom function does some funky stuff (2nd i

5条回答
  •  庸人自扰
    2020-12-24 01:20

    Take a look at this tutorial. Here the author uses two Matrix objects to manage translations and scalling. I suggest you to use matrices, otherwise calculating new coordinates can be tricky and tedious. Your problem is caused by not managing translations correctly. Note: in the tutorial, inside OnDraw(), it misses the canvas.concat(matrix), put it right after canvas.drawBitmap(...)

提交回复
热议问题