重置Bitmap大小
Bitmap bitMap = BitmapFactory.decodeFile(path); int width = bitMap.getWidth(); int height = bitMap.getHeight(); // 設置想要的大小 int newWidth = 500; int newHeight = 400; // 計算縮放比例 float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // 取得想要縮放的matrix參數 Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); // 得到新的圖片 bitMap = Bitmap.createBitmap(bitMap, 0, 0, width, height, matrix, true);
Bitmap轉角度
Bitmap bm = BitmapFactory.decodeByteArray(imgdata, 0,imgdata.length); Matrix matrix = new Matrix(); matrix.preRotate(270); bm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),bm.getHeight(), matrix, true);
imgdata為camera開發的時候的圖片數據。
這里其實找到了bitmap就OK了。