Android -- 重置Bitmap大小&&Bitmap转角度

重置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了。

 

 

转载请注明出处:http://www.cnblogs.com/yydcdut/p/3744875.html

posted @ 2014-05-23 07:33  我爱物联网  阅读(5510)  评论(0编辑  收藏  举报
AmazingCounters.com