-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get touched coordinates on Image #11
Comments
I have private PointF variables "last" and "start" which track the points the raw user touch data. You can make a public method which returns either of these points. It doesn't make sense to add this to TouchImageView as I would like to keep the raw touch data abstracted away. |
For other people seeing this - to translate the touch event to the actual image coordinates you have to do some mathematical magic. I got this from StackOverflow. Set your activity/fragment as @Override
public void onClick(View v) {
Ln.d("Clicked image on: " + mMapImageView.last.x + ", " + mMapImageView.last.y);
Matrix m = new Matrix();
mMapImageView.matrix.invert(m);
float[] pts = {mMapImageView.last.x, mMapImageView.last.y };
m.mapPoints(pts);
Ln.d("Mapped to real image: " + pts[0] + ", " + pts[1]);
} |
Hi @sebastianwr, @MikeOrtiz |
Actually, I switched to a WebView containing an image map. That was much easier to realize on Android for my special use case. |
@sreekanth100k First, you'll need to make a RectF of the bounds of your rectangle in the image. The coordinates of this RectF should range from 0 to 1. Next, you'll want to turn the method transformCoordTouchToBitmap from private to public.
|
Thanks a lot for the answers :) |
Call resetZoom() |
Thanks a lot Mike, Can I implement a swipe for the screen some how? I mean if I swipe the image should switch |
I just found this OnSwipeTouchListener: http://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures. You could set OnSwipeLeft() and OnSwipeRight() to switch the image. There could be some issues as TIV will want to fling the image and the Swipe Listener will try to switch the image, so you will need to work out what functionality you want here. Maybe just switch the image when getCurrentZoom() == 1. |
Ok I understand that :) Thanks a lot Mike :) |
Hi Mike, |
Make sure you get the most updated code. I pushed v1.2 to master earlier this week. |
will the new version serve all the purposes that the old version served? |
A couple functions have been deprecated including transformCoordTouchToBitmap. But the method is still available privately. You'll need to make it public for your purposes. |
I am geting and error when I replaced the old version with the new one. |
Did you modify TouchImageView? If so, any changes you made to it must be ported to v1.2. |
Hi Mike, |
Hi Mike, |
This worked for me
|
Worked for me as well, Thanks a ton bro |
It it this, what you want ? #357
|
@androidovshchik before you work with reflections, I recommend to make a pull request |
Get where the user is touching in the image (x,y) with the image reference in any zoom?
Is it possible?
The text was updated successfully, but these errors were encountered: