Bitmap尺度变换
生活随笔
收集整理的這篇文章主要介紹了
Bitmap尺度变换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 Bitmap bitMap = BitmapFactory.decodeFile(path);
2 int width = bitMap.getWidth();
3 int height = bitMap.getHeight();
4 // 設置想要的大小
5 int newWidth = 500;
6 int newHeight = 400;
7 // 計算縮放比例
8 float scaleWidth = ((float) newWidth) / width;
9 float scaleHeight = ((float) newHeight) / height;
10 // 取得想要縮放的matrix參數
11 Matrix matrix = new Matrix();
12 matrix.postScale(scaleWidth, scaleHeight);
13 // 得到新的圖片
14 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);?
總結
以上是生活随笔為你收集整理的Bitmap尺度变换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怀孕梦到下雨下雪是什么意思
- 下一篇: 梦到的人现实中存在吗