Attempting to get Bitmap pixel from an ImageView's onTouchListener?

Check into the ScaleType property. You'll have to do the math on the original image, based on the results of getScaleType(), but it's worth checking out.

The problem with ScaleType is that it just returns the method they use for scaling, not the actual ratio by which it is scaled. – Eighty Apr 18 at 4:48.

I am displaying a Bitmap on an ImageView. When the ImageView is tapped, I would like to get the pixel x/y coordinates for the Bitmap where it was tapped. I have registered the ImageView's onTouchListener, and within the onTouch method, I use getX and getY to get the location of the touch.

The problem is that the image within the ImageView may be larger than the view itself, so it is scaled down to fit the screen. The x and y coordinates returned, then, are the coordinates of the view, but not necessarily the coordinates of the corresponding pixel on the Bitmap. Can I get some sort of scale factor to know how much it was resized?

Or if not, could someone suggest how I could go about getting the information I need? What's most important is that I can get the pixel coordinates - if I have to change the view type, that's alright. Also, sometimes the bitmap is smaller than the screen, so it scales it up.

In this scenario, it is possible that the x and y received from the MotionEvent are outside the bounds of the actual Bitmap.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions