class OrientationUtils {

    public static int computeImageOrientation(int screenRotationDegrees,
                                              int cameraRotationDegrees,
                                              boolean cameraIsMirrored) {
        int rotation;

        if (cameraIsMirrored) {
            rotation = -(screenRotationDegrees + cameraRotationDegrees);
        } else {
            rotation = screenRotationDegrees - cameraRotationDegrees;
        }

        return (rotation + 360 + 360) % 360;
    }

}