如何在Android中进行放大/缩小,旋转起来如何在、Android

2023-09-12 09:55:42 作者:屌丝绅士、

我想申请拖动,放大/缩小,旋转使用多点触控来两张图片。一        图像被放置在另一个的顶部。运用这些动作后

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.

主要问题是

1.How以每次申请行动,两个图像,一个图像?

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

2.How从当前显示的图像切换到另一个图像            (这布局我应该使用)?

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

3.How用户可以拥有一个设施,旋转或使用多点触控缩放图像?

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

我缺少的是什么,很抱歉的名单 - :)

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

推荐答案

1)你必须保持做Bitmap1改造,并再次将其应用到Bitmap2。例如,你可以使用使用触摸事件,以便计算出一个矩阵,将其应用到两个位图。

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)我不知道要uderstand你想要做什么。我的理解是:你有多个ImageView的(可以由放置在另一个上面2幅)浮动的布局,并且要选择其中一个来调整大小/旋转。 为了做到这一点,你可以简单地使用的ImageView的ontouch事件。

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)旋转+放大与多点触控是不容易在Android中,大量的code必须写入,以使其很好地工作。我建议你​​使用现有的库。我用这个和它的工作就像一个魅力: http://$c$c.google.com/p/android-multitouch-controller/

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/

您可以提供的样本http://$c$c.google.com/p/android-multitouch-controller/source/browse/trunk/demo/MTPhotoSortr/src/org/metalev/multitouch/photosortr/PhotoSortrView.java你可以在任何时候retreive新的中心,角度和 mImages(我).getCenterX() mImages更新的图像缩放比例(一).getAngle() mImages(我).getScaleX(),... 使用这个值,你可以复制的转换(旋转,缩放,平移)上的另一个位图。

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.