Get Canvas coordinates after scaling up/down or dragging in android

前端 未结 2 1396
终归单人心
终归单人心 2020-12-02 13:40

I\'m developing an application in which I\'m pasting images, doing drawing and painting on canvas. This app can also Scale up/down the canvas or drag it to different locatio

2条回答
  •  被撕碎了的回忆
    2020-12-02 14:16

    Done it finally by myself.

    Draw everything by applying this formula to (px,py) coordinates:

    float px = ev.getX() / mScaleFactor + rect.left;
    float py = ev.getY() / mScaleFactor + rect.top;
    rect = canvas.getClipBounds();
    //Get them in on Draw function and apply above formula before drawing
    

提交回复
热议问题