Zooming in and out of instance code for Bitmap in android

  • 2020-05-17 06:21:34
  • OfStack

 
/**Bitmap Amplification method */ 
private static Bitmap big(Bitmap bitmap) { 
Matrix matrix = new Matrix(); 
matrix.postScale(1.5f,1.5f); // The ratio of length to width  
Bitmap resizeBmp = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true); 
return resizeBmp; 
} 
/**Bitmap Reduction method */ 
private static Bitmap small(Bitmap bitmap) { 
Matrix matrix = new Matrix(); 
matrix.postScale(0.8f,0.8f); // The ratio of length to width  
Bitmap resizeBmp = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true); 
return resizeBmp; 
} 

Related articles: