android - Magnifying part of the canvas when touched -


I have a custom view that spreads SurfaceView I am pulling a picture on the canvas when the user touches a point on the canvas , Then I want to show a big view of the area around the touched coordination. And preferably, as it rotates around the finger, accordingly, I would like to update the contents of magnified scenes.

I was wondering if the Android platform has supported this kind of functionality basically if any, then none of you can tell me a good example that I started to share or share ideas. How to apply it. I do not do such a lot of 2D or 3D graphics and still trying to understand the canvas and matrix classes what I can use.

I searched for the same question for anyone who searched the forum. Therefore, pls does not flag to ask me a question already present.

No more - I am not using OpenGL-E or any such third party library (yet).

Thanks all.

To zoom the image that you are portraying on the canvas: < P> Create a bitmap shader (using bitmap of image), a matrix and a paint:

  shader = new bitmapshader (BMP, tile mode. Clipper, tile mode. Clamp); Matrix = new matrix (); ShaderPaint = new paint (); ShaderPaint.setShader (Shader);   

Record touch status on touch events (eg in one point):

  ZoomPos. X = event.getX (); ZoomPos.y = event.getY ();   

... and set up the matrix of shader (I do this on every touch, maybe a better way):

  matrix .set (); Matrix. PostScale (2f, 2f); Matrix. PostTranslate (-zoomPos.x, -zoomPos.y); Shader.setLocalMatrix (matrix);   

Then in the drawing code, create a circle using shader paint.

  canvas.drawCircle (zoomPos.x, zoomPos.y, size_of_the_circle, shaderPaint);    matrix. PostTranslate (-zoomPos.x, -zoomPos.y);   

can be changed with one:

  matrix. PostScale (2f, 2f, zoomPos.x, zoomPos.y);   

This can change the scale factor without breaking the offset.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -