Tuesday, April 5, 2011

How to zoom in and out to a bitmap without loosing resolution ?

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);
From stackoverflow
  • Keep the original bitmap unchanged. Everytime you resize you work on a clone of that original.

0 comments:

Post a Comment