Road to Android Development-------Picture Rotation Adaptive

In this case, the rotation adaptation size is actually mainly to modify the internal bitmap of the picture, which is useful to the matrix class Matrix.

There is a method postRotate in   Matrix . This method passes in a value of type int to indicate the angle of rotation deg

Code:

//创建矩阵类
Martix martix = new Martix();
//旋转90度
martix.postRotate(90)
//oldBitmap 原始图片的bitmap 返回一个新的已经旋转90的bitmap
Bitmap newBitmap = Bitmap.createBitmap(oldBitmap,0,0,oldBitmap.getWidth(),oldBitmap.getHieght(),martix,false);
//此时将新的bitmap传入imageView即可
imageView.setImageBitmap(newBitmap);

 

Guess you like

Origin blog.csdn.net/z1455841095/article/details/106503443