int ScaleAngle = - 2 //旋转角度 |
/* ScaleTimes=1,维持1:1的宽高比例 */ |
int newWidth = widthOrig * ScaleTimes; |
int newHeight = heightOrig * ScaleTimes; |
float scaleWidth = (( float ) newWidth) / widthOrig; |
float scaleHeight = (( float ) newHeight) / heightOrig; |
Matrix matrix = new Matrix(); |
/* 使用Matrix.postScale设定维度 */ |
matrix.postScale(scaleWidth, scaleHeight); |
/* 使用Matrix.postRotate方法旋转Bitmap */ |
// matrix.postRotate(5*ScaleAngle); |
matrix.setRotate( 5 * ScaleAngle); |
/* 建立新的Bitmap对象 */ |
Bitmap resizedBitmap = Bitmap.createBitmap(mySourceBmp, 0 , 0 , |
widthOrig, heightOrig, matrix, true ); |