日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

android获取图片方向并旋转,Android 判断imageview角度并旋转

發(fā)布時(shí)間:2025/3/8 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android获取图片方向并旋转,Android 判断imageview角度并旋转 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

/**

* 讀取照片exif信息中的旋轉(zhuǎn)角度

*

* @return角度 獲取從相冊(cè)中選中圖片的角度

*/

public static float readPictureDegree(String path) {

int degree = 0;

try {

ExifInterface exifInterface = new ExifInterface(path);

int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

switch (orientation) {

case ExifInterface.ORIENTATION_ROTATE_90:

degree = 90;

break;

case ExifInterface.ORIENTATION_ROTATE_180:

degree = 180;

break;

case ExifInterface.ORIENTATION_ROTATE_270:

degree = 270;

break;

}

} catch (Exception e) {

e.printStackTrace();

}

return degree;

}

/**

* 旋轉(zhuǎn)圖片,使圖片保持正確的方向。

*/

public static Bitmap rota(float degrees,Bitmap bitmap){

Matrix matrix = new Matrix();

matrix.setRotate(degrees, bitmap.getWidth() / 2, bitmap.getHeight() / 2);

Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);

if (null != bitmap) {

bitmap.recycle();

}

return bmp;

}

總結(jié)

以上是生活随笔為你收集整理的android获取图片方向并旋转,Android 判断imageview角度并旋转的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。