首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Bit地图缩放的一个方法

2012-08-26 
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;
        }
 
}


热点排行