如何在Android中同时执行放大/缩小、旋转
我想使用多点触控对两个图像应用拖动、放大/缩小、旋转。一个 图像放置在另一个图像的顶部。应用这些操作后,
从上面的两个图像 通过应用操作进行的更改。
我成功地将缩放/拖动应用于顶部图像,并从中创建了新图像。
主要问题是
1.如何对两个图像应用动作,一次一个图像?
2.如何从当前显示的图像切换到另一张图像 (我应该使用哪种布局)?
3.用户如何使用多点触控来旋转或缩放图像?
我缺少什么,抱歉列表 -:)
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
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 -:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要保持对 Bitmap1 的转换,然后再次将其应用到 Bitmap2。例如,您可以使用通过触摸事件计算的矩阵,以便将其应用于两个位图。
我不太明白你想做什么。我的理解是:您有多个图像视图(可以由放置在另一个图像之上的 2 个图像组成)浮动在布局上,并且您想选择其中一个来调整其大小/旋转它。
为此,您只需使用 imageView 的 ontouch 事件即可。
使用多点触控进行旋转+缩放在 Android 中并不容易,必须编写大量代码才能使其正常工作。我建议您使用现有的库。我用过这个,它的效果就像一个魅力:
https://github.com/lukehutch/android-multitouch-controller
您可以在提供的示例中看到 http://code.google.com/p/android-multitouch-controller/source/browse/trunk/demo/MTPhotoSortr/src/org/metalev/multitouch/photosortr/PhotoSortrView .java,您可以随时检索
mImages(i).getCenterX()
、mImages(i)中更新图像的新中心、角度和比例.getAngle()、
mImages(i).getScaleX()
、...使用此值,您可以在另一个位图上复制变换(旋转、缩放、平移)。
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.
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.
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:
https://github.com/lukehutch/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.