2

I am trying to implement pinch zoom and it is working but when i zoom out and then zoom in again the resolution of the image(bitmap) decreases. I am aware that this is just normal behavior of my code and i want to know how to do this with right way .

here is the relevant code :

Matrix matrix = new Matrix() ;
float scale = newDist / oldDist;
matrix.postScale(scale, scale, mid.x, mid.y);
int width = mutable.getWidth() ;
int height = mutable.getHeight() ;
mutable = Bitmap.createBitmap(mutable, 0, 0, width, height, matrix, false);
Tony
  • 1,603
  • 3
  • 21
  • 40

2 Answers2

6

Keep the original bitmap unchanged. Everytime you resize you work on a clone of that original.

xandy
  • 27,357
  • 8
  • 59
  • 64
2

There is a tutorial here:

http://blogs.sonyericsson.com/wp/2010/05/18/android-one-finger-zoom-tutorial-part-1/

kikoso
  • 673
  • 1
  • 6
  • 17