In landscape orientation, I using myImageView.setImageBitmap(myBitmap)
and using an ontouch
listener to getX
and getY
and adjust for location of myImageView
(same as getRawX
and getRawY
). I then use bitmapToMat
to build a MAT to process the image more with OpenCV. I found two resizing scenarios where the onTouch
location will draw a circle exactly where I touched but at times the location will be outside the Mat and cause a NPE and fail during processing.
Scenario 1: resize(myImageView.getWidth(), myImageView.getHeight())
Scenario 2: resize(myImageView.getHeight(), myImageView.getWidth())
and
x = x(myImage.getHeight()/myImageView.getWidth())
y = y(myImage.getWidth()/myImageView.getHeight())
If I dont change the x,y I can click everywhere in image w/o the NPE but the circle drawn is nowhere near where I touched.
After processing I matToBitmap(myMAT, newBitmap)
and myImageView.setImageBitmap(newBitmap)
.
I am obviously missing something but is there there a simple way to get the touch location and use that location in a MAT? Any help would be awesome!