radityakurnianto

BitmapOrientation

Sep 20th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. try{
  2.             ExifInterface exifInterface = new ExifInterface(path);
  3.             int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
  4.  
  5.             int rotation = 0;
  6.             switch (orientation){
  7.                 case ExifInterface.ORIENTATION_ROTATE_90 :
  8.                     rotation = 90;
  9.                     break;
  10.                 case ExifInterface.ORIENTATION_ROTATE_180 :
  11.                     rotation = 180;
  12.                     break;
  13.                 case ExifInterface.ORIENTATION_ROTATE_270 :
  14.                     rotation = 270;
  15.                     break;
  16.                 default: break;
  17.             }
  18.  
  19.             Matrix matrix = new Matrix();
  20.             matrix.postRotate(rotation);
  21.  
  22.             decode = BitmapFactory.decodeFile(path, options);
  23.             rotatedBitmap = Bitmap.createBitmap(decode, 0, 0, decode.getWidth(), decode.getHeight(), matrix, true);
  24.         } catch (IOException e){
  25.             Log.d("ROTATION ERROR", e.getCause() + " " + e.getMessage());
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment