private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
        matrix.getValues(m);
        float origW = getDrawable().getIntrinsicWidth();
        float origH = getDrawable().getIntrinsicHeight();
        float transX = m[Matrix.MTRANS_X];
        float transY = m[Matrix.MTRANS_Y];
        float finalX = ((x - transX) * origW) / getImageWidth();
        float finalY = ((y - transY) * origH) / getImageHeight();

        if (clipToBitmap) {
            finalX = Math.min(Math.max(finalX, 0), origW);
            finalY = Math.min(Math.max(finalY, 0), origH);
        }

        return new PointF(finalX, finalY);
    }
This function will transform the coordinates in the touch event to the coordinate
system of the drawable that the imageview contain

@param x            x-coordinate of touch event
@param y            y-coordinate of touch event
@param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
                    to the bounds of the bitmap size.
@return Coordinates of the point touched, in the coordinate system of the original drawable.
app/src/main/java/com/rozdoum/socialcomponents/views/TouchImageView.java