各种android设备中的图片旋转角度问题

各种android设备中的图片旋转角度问题,android,orientation,Android,Orientation,我正在开发一个小应用程序,使用bitmap.createScaledBitmap()重新调整位图大小。我正在使用下面的代码来获取单击图像的旋转角度,并根据旋转角度来调整图像大小。这在三星galaxy s4(Android 4.3 Jellybean)中运行良好,没有任何问题,但在摩托罗拉Moto E(Android 4.4.4)中没有相同的代码:它没有返回角度,因此我无法正确调整图像大小 请指导我这个问题。我如何在各种设备上处理这个问题。提前谢谢 public int getCameraPhot

我正在开发一个小应用程序,使用
bitmap.createScaledBitmap()
重新调整位图大小。我正在使用下面的代码来获取单击图像的旋转角度,并根据旋转角度来调整图像大小。这在三星galaxy s4(Android 4.3 Jellybean)中运行良好,没有任何问题,但在摩托罗拉Moto E(Android 4.4.4)中没有相同的代码:它没有返回角度,因此我无法正确调整图像大小

请指导我这个问题。我如何在各种设备上处理这个问题。提前谢谢

public int getCameraPhotoOrientation(){
    int rotate = 0;
    try {
       this.getContentResolver().notifyChange(Uri.fromFile(outputImage), null);
        ExifInterface exif = new ExifInterface(outputImage.getAbsolutePath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

    switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_270:
        rotate = 270;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        rotate = 180;
        break;
    case ExifInterface.ORIENTATION_ROTATE_90:
        rotate = 90;
        break;
    }

   // Log.i("RotateImage", "Exif orientation: " + orientation);
   // Log.i("RotateImage", "Rotate value: " + rotate);
    utilitycls.showCustomToastMessage(this,""+orientation,0);
} catch (Exception e) {
    e.printStackTrace();
}
return rotate;}

正如你所建议的,我在交换机中使用了ExiFinInterface.ORIENTATION\u NORMAL。我的摩托罗拉设备返回-1或Intation。根据方向,我正在设置宽度和高度。它对S4和摩托罗拉都有效。但对于其他设备,我仍然一无所知

rotate=getCameraPhotoOrientation()//(这个)//

}

        // utilitycls.showCustomToastMessage(this,"Rotation::"+rotate,1);


        if(rotate == 0 || rotate == 180)
        {
            finalW=480;
            finalH=270;
              //  resizedBitmap = Bitmap.createScaledBitmap(bmp,  480,270, false);
        }
        else if(rotate == 90 || rotate == 270)
        {
            bmp=RotateBitmap(bmp, rotate);

            finalW=270;
            finalH=480;

        }
        else 
        {
            if(bitmapW >= bitmapH)
            {
                finalW=480;
                finalH=270;
            }
            else
            {
                finalW=270;
                finalH=480;
            }



        }



        resizedBitmap = Bitmap.createScaledBitmap(bmp,  finalW,finalH, false);










public int getCameraPhotoOrientation(){
    int rotate = 0;
    try {
       this.getContentResolver().notifyChange(Uri.fromFile(outputImage), null);
      //  File imageFile = new File(imagePath);

    ExifInterface exif = new ExifInterface(outputImage.getAbsolutePath());
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

    switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_270:
        rotate = 270;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        rotate = 180;
        break;
    case ExifInterface.ORIENTATION_ROTATE_90:
        rotate = 90;
        break;
    case ExifInterface.ORIENTATION_NORMAL:
        rotate = 0;
        break;
    case 0:
        rotate = -1;
        break;
    }

   // Log.i("RotateImage", "Exif orientation: " + orientation);
   // Log.i("RotateImage", "Rotate value: " + rotate);
    utilitycls.showCustomToastMessage(this,""+orientation,0);
} catch (Exception e) {
    e.printStackTrace();
}
return rotate;