我了解我可以通过
在Android中轮换ImageView
matrix.postRotate(finalOrientation - initOrientation, width, height);
但我希望直接将其设为finalOrientation
,而不是按差异finalOrientation - initOrientation
旋转它。
所以我期待的是:
matrix.setOrientation(finalOrientation);
我该怎么做?
答案 0 :(得分:3)
完美!谢谢@Bette Devine! 为方便起见,我做了一个功能。
public Bitmap rotateBmp(Bitmap bmp){
Matrix matrix = new Matrix();
//set image rotation value to 90 degrees in matrix.
matrix.postRotate(90);
//supply the original width and height, if you don't want to change the height and width of bitmap.
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),bmp.getHeight(), matrix, true);
return bmp;
}
我不得不用缩小的图像来做这件事。当我尝试使用全尺寸图像时,我得到了“java.lang.OutOfMemoryError”。 :(
答案 1 :(得分:0)
请参阅以下链接:
http://docs.xamarin.com/guides/android/application_fundamentals/handling_rotation/
希望这会对你有所帮助.. :)
答案 2 :(得分:0)
Matrix matrix = new Matrix();
//set image rotation value to 90 degrees in matrix.
matrix.postRotate(90);
//supply the original width and height, if you don't want to change the height and width of bitmap.
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, newWidth, newHeight, matrix, true);