android - convert touched value to points based on matrix -



android - convert touched value to points based on matrix -

i translating , scaling image matrix, have matrix values . matrix value want convert touch coordinates position getting matrix. should ? please help me asap.

private void drawpoint(float x, float y, float pressure, float width) { // left tx of matrix // top ty of matrix float curx = (x - left) / (scale * scale); float cury = (y - top) / (scale * scale); canvas.drawpoint((curx - left), (cury - top) , mpaint); }

i know it's old post, had same problem.

i have image applied matrix transformation, first resize it, , translation.

image = new matrix(); image.setscale(zoom, zoom); paint drawpaint = new paint(); drawpaint.setantialias(true); drawpaint.setfilterbitmap(true); float centerscaledwidth = image_center.x * zoom / 2; float centerscaledheigth = image_center.y * zoom / 2; image.posttranslate(screen_center.x - centerscaledwidth, screen_center.y - centerscaledheigth); canvas.drawbitmap(bmp, image, drawpaint);

to points touched on image trace of matrix image , method:

@override public boolean ontouchevent(motionevent ev) { final int action = ev.getaction(); switch (action & motionevent.action_mask) { case motionevent.action_down: { final float x = ev.getx(); final float y = ev.gety(); float[] pts = {x, y}; matrix m = new matrix(); // magic, set new matrix m // inverse of // matrix applied image image.invert(m); // transform points using inverse matrix m.mappoints(pts); // have ....... log.i("transformed", pts[0] +" "+pts[1]); break; } } homecoming super.ontouchevent(ev); }

android matrix android-canvas

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -