0

我知道我可以ImageView在 Android 中通过

matrix.postRotate(finalOrientation - initOrientation, width, height);

但我想将其设置为finalOrientation直接,而不是按差异旋转它,finalOrientation - initOrientation.

所以我期待类似的东西:

matrix.setOrientation(finalOrientation);

我怎样才能做到这一点?

4

3 回答 3

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”。: (

于 2014-11-05T22:09:42.410 回答
1
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);
于 2013-11-05T05:55:39.557 回答
0

请参考以下链接:

http://docs.xamarin.com/guides/android/application_fundamentals/handling_rotation/

于 2013-11-05T04:31:12.980 回答