I have set a prescaled Bitmap as ImageView's source. Then I've read Matrix of an ImageView
and shift Bitmap of an ImageView via matrix.postTranslate(shiftX, shiftY)
.
Now I want to zoom in / out and image while maintaining center of ImageView
at the same point of Bitmap that was before scale.
If I try to zoom in an image with matrix.postScale(zoom, zoom)
, point that I want to maintain (blue dot) shifts to other place (purple dot).
I have tried several different ways to shift Bitmap back, but I cant get it to work correctly. I know initial Bitmap size, ImageView size, distances marked by doted line. Tried to calculate needed shift and use matrix.postTranslate(-zoomshiftX, -zoomshiftY)
afterwards, but it doesn't shift correctly.
Even found out, that underlying Bitmap's pixel count doesnt change after matrix.postScale() function and tried matrix.postTranslate(-zoomshiftX/zoom, -zoomshiftY/zoom) - but still no luck.
How do I achieve such zoom?