canvas - Android Scale a bitmap image -


In my application there are 9 bitmap images in the 3 bit 3x3 grid, they are all displayed on the screen and depend on it How to touch the image (tap, double tap, pinch, zoom, drag), how the user "action-addon" needs to perform different tasks.

For example, if I tap on an image, then it needs to rotate around its vertical entrance completely, then stop it.

Currently I am using SurfaceView with the onTouchEvent (..) method. The way I thought I could enliven it, I am scaling the width of the image from 1 to -1 to level 1. I'm trying to use the matrix, but I can not find the image to stay focused on this place. Please help me fix it or suggest an alternative / better way to do this.

My current code is just a test if the b is true, then the method will try to scale the bitmap if b < / B> is false then it will normally attract the bitmap.

  Dood with public zeros (canvas canvas, boolean B) {matrix M = new matrix (); Float scale = .5f; M.setScale (scale, 1f); M.postTranslate (mx, me); If (! B) canvas.drawBitmap (mbitmap, mx, my, null); Else canvas.drawBitmap (mbitmap, m, null); } Try it instead of    

postTranslate Matrix Pretranslate (-centerX, -centerY); Matrix. PostTranslate (centerX, centerY);

Where centerX is the center of Y bitmap

UPDATE

You can play with graphics. Replace the matrix on the Android Access the camera to the main view and get the synthetic conversion conversion matrix t.getMatrix () and replace it one You can customize it anywhere Because it is matrix from main view but only addressed to present that special child.

Do something like this @ Override Protected Boolean received childstatic conversion (see child, change t) {matrix matrix = t. Metatix ​​(); Int centX = (child.getWidth () / 2); Int center y = (child.getHeight () / 2); T.clear (); T.setTransformationType (Transformation.TYPE_MATRIX); MCamera.save (); If (child == getChildAt (0)) {mCamera.translate (pixels on the right, down to pixels, z axis); MCamera.getMatrix (matrix); MCamera.restore (); Matrix Pretranslate (-centerX, -centerY); Matrix. PostTranslate (centerX, centerY); } Back true; }

Also do not forget to set setStaticTransformationsEnabled (true) ; Somewhere the creator of the grid

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -