Bit地图缩放的一个方法

Bitmap缩放的一个方法public static Bitmap bitmapRoom(Bitmap srcBitmap,int newHeight,int newWidth) {i

Bitmap缩放的一个方法
public static Bitmap bitmapRoom(Bitmap srcBitmap,int newHeight,int newWidth)
{
  int srcWidth = srcBitmap.getWidth();  
        int srcHeight = srcBitmap.getHeight();   
 
        float scaleWidth = ((float) newWidth) / srcWidth;  
        float scaleHeight = ((float) newHeight) / srcHeight;  
 
        Matrix matrix = new Matrix();  
        matrix.postScale(scaleWidth, scaleHeight);    
        Bitmap resizedBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcWidth,  
          srcHeight, matrix, true);
        if(resizedBitmap != null)
        {
         return resizedBitmap;
        }
        else
        {
         return srcBitmap;
        }
 
}