2013-11-05 2 views
0

Я понимаю, что может вращаться в Android в ImageView поУстановить ориентацию ImageView прямо в Android?

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

Но я хочу установить его в качестве finalOrientation непосредственно вместо поворота ее по разнице, finalOrientation - initOrientation.

Так что я ожидал что-то вроде:

matrix.setOrientation(finalOrientation); 

Как я могу это сделать?

+0

Что нужно для ориентации, вы можете сделать это в самом повороте –

+0

вы можете привести пример .. используя некоторые реальные значения .. –

ответ

0

Пожалуйста, обратитесь по следующей ссылке:

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

Надеется, что это поможет вам .. :)

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); 
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», когда я попытался сделать это с полноразмерным изображением. : (

Смежные вопросы