如何拍摄X吸取缩放位点,y坐标构成的图像视图缩放、视图、坐标、图像

2023-09-07 04:59:08 作者:你再難遇我

请帮我

我开发一个Android应用程序,以显示在图像视图捏变焦能力和拖拽就能位图(图像视图的界限是一样的设备屏幕大小)。我只是缩放位图,并显示在图像视图

I'm developing an android application to display a pinch zoom-able and drag-able bit map in a image view(Image view's boundaries are same as device screen size). I'm only zooming the bit map and show it in the image view

我要的是

在设备屏幕上点击的地方得到X上的Y位置,并在我的位图点击的地方正好画一个点它像位图上标记您的位置

When click a place on the device screen get that X an Y positions and draw a dot exactly in the place where I clicked on the bitmap Its like marking your location on the bit map

下面是一个描述性的图像(抱歉,我不能把它上传到这里,因为我有低信誉)

Here is a descriptive image (Sorry I couldn't upload it to here because i have low reputation)

https://m.xsw88.com/allimgs/daicuo/20230907/4689.png.jpg

作为图像显示我想要得到的X2,图像视图的Y2位置,并绘制红点在X1,位图上Y1位置

as the image displays i want to get the x2, y2 positions of image view and draw the red dot in x1,y1 position on the bit map

这将是非常有助于全力为我,如果你能给我一些codeS或建议

It will be very help full for me if you can give me some codes or advice

感谢您

推荐答案

我已经经历了同样的问题了,得到了解决。

I have gone through same problem and got resolved.

试试这个,

*的获取接触点X,Y * 的

   int x = (int) event.getX();
   int y = (int) event.getY();

2。计算逆矩阵

            // calculate inverse matrix
            Matrix inverse = new Matrix();

3。让您的ImageView的矩阵                getImageMatrix()反(反向);

3. Get your ImageView matrix getImageMatrix().invert(inverse);

4。您的地图坐标实际图片

        // map touch point from ImageView to image
        float[] touchPoint = new float[] { event.getX(), event.getY() };
        inverse.mapPoints(touchPoint);

*的 4。让您的实际X,图像Y * 的

        x = (int) touchPoint[0];
        y = (int) touchPoint[1];