我已经设置了prescaled位图的ImageView源。然后,我读过的矩阵的ImageView
并通过 matrix.postTranslate(shiftX,缩骨)
转向了ImageView的位图
I have set a prescaled Bitmap as ImageView's source. Then I've read Matrix of an ImageView
and shift Bitmap of an ImageView via matrix.postTranslate(shiftX, shiftY)
.
现在我要放大/缩小和形象,同时保持的ImageView
的中心位图的相同点是规模之前。
Now I want to zoom in / out and image while maintaining center of ImageView
at the same point of Bitmap that was before scale.
如果我尝试在图片放大与 matrix.postScale(变焦,变焦)
,点,我想保持(蓝点)转移到其他地方(紫点)。
If I try to zoom in an image with matrix.postScale(zoom, zoom)
, point that I want to maintain (blue dot) shifts to other place (purple dot).
我已经尝试了几种不同的方法来移位图回来,但我不能让它正常工作。我知道,最初的位图大小,ImageView的大小,特点是点线的距离。试图计算需要移位,并使用 matrix.postTranslate(-zoomshiftX,-zoomshiftY)
之后,但它不能正常移动。
I have tried several different ways to shift Bitmap back, but I cant get it to work correctly. I know initial Bitmap size, ImageView size, distances marked by doted line. Tried to calculate needed shift and use matrix.postTranslate(-zoomshiftX, -zoomshiftY)
afterwards, but it doesn't shift correctly.
即使发现了,matrix.postScale()函数后潜在的位图的像素数并没有改变,并试图matrix.postTranslate(-zoomshiftX /变焦,-zoomshiftY /缩放) - 但仍没有运气
Even found out, that underlying Bitmap's pixel count doesnt change after matrix.postScale() function and tried matrix.postTranslate(-zoomshiftX/zoom, -zoomshiftY/zoom) - but still no luck.
我如何实现这种放大?
看看我的问题就在这里建立一个可缩放的ViewGroup。我所描述的code段从我的端到端解决方案,以及它的一些可能会有所帮助。
Take a look at my question here regarding creating a zoomable ViewGroup. I've described code snippets from my end solution, and some of it might be helpful.
Extending RelativeLayout的,并覆盖dispatchDraw()创建一个可缩放的ViewGroup