Java tutorial
//package com.java2s; //License from project: Apache License import android.view.Surface; public class Main { public static int getOrientation(int rotation, boolean upsideDown) { if (upsideDown) { switch (rotation) { case Surface.ROTATION_0: return 270; case Surface.ROTATION_90: return 180; case Surface.ROTATION_180: return 90; case Surface.ROTATION_270: return 0; } } else { switch (rotation) { case Surface.ROTATION_0: return 90; case Surface.ROTATION_90: return 0; case Surface.ROTATION_180: return 270; case Surface.ROTATION_270: return 180; } } return 0; } }