How to perform zoom in/out ,rotation together in Android

只谈情不闲聊 提交于 2019-11-29 23:19:20

问题


I want to apply drag,zoom in/out,rotate using multitouch to two images .one image is placed on the top of the other. after applying these action

Create a image

from above two images after changes made by applying actions.

I succeed in apply zoom/drag to top image ,created new image from that.

main problem is

1.How to apply action to two images, one image at a time ?

2.How to switch to another image from currently showing image (which layout I should use)?

3.How user can have a facility to rotate or zoom a image using multitouch ?

What I am missing, Sorry for the list -:)


回答1:


1) You need to keep the transformation done to Bitmap1 and apply it again to Bitmap2. for example you can use a Matrix calculated using touch events in order to apply it to the two Bitmaps.

2) I am not sure to uderstand what you want to do. What i understand is: you've got multiple imageview (that can be composed of 2 images placed on top of another) floating on the layout and you want to select one of them to resize / rotate it. In order to do that you can simply use the ontouch event of an imageView.

3) Rotate + zoom with multitouch is not easy in Android, lots of code have to be written in order to make it work nicely. I suggest you to use an existing library. I used this one and it worked like a charm: http://code.google.com/p/android-multitouch-controller/

You can see in the sample provided http://code.google.com/p/android-multitouch-controller/source/browse/trunk/demo/MTPhotoSortr/src/org/metalev/multitouch/photosortr/PhotoSortrView.java that you can retreive at any time the new center, angle, and scale ratio of the updated images in mImages(i).getCenterX(), mImages(i).getAngle(), mImages(i).getScaleX(), ... Using this values you can replicate the transformations (rotation, scaling, translation) on another Bitmap.



来源:https://stackoverflow.com/questions/5256421/how-to-perform-zoom-in-out-rotation-together-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!