一个图片满屏显示

private Bitmap CreatMatrixBitmap(int resourcesID, float screen_width,
   float screen_height) {//screen_width,screent_height是屏幕的宽和高,resourcesID是所要资源的图片id
Bitmap bitMap = null;
//代表那个背景图片
bitMap = BitmapFactory.decodeResource(getResources(), resourcesID);
//得到图片的宽和搞
int bitWidth = bitMap.getWidth();
int bitHeight = bitMap.getHeight();
float scaleWidth = screen_width/ (float) bitWidth;//屏幕的宽和高除以图片的宽和高
float scaleHeight = screen_height/ (float) bitHeight;
 
//图片处理
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
bitMap = Bitmap.createBitmap(bitMap, 0, 0, bitWidth, bitHeight, matrix,
true);
return bitMap;
    }
posted @ 2014-07-22 15:36  墨棋  阅读(129)  评论(0编辑  收藏  举报