diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2013-11-29 17:16:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-05 19:28:16 +0100 |
commit | 13d7f835fad59fbda69bfa160e21f19d095ac8d5 (patch) | |
tree | 6c32fca0a5af8c855c3b19c1d723a3133608c05b /src/plugins/android/src/wrappers | |
parent | 99bebdbb7dbdde259bc06e86079daebb17482c64 (diff) |
Android: fix camera viewfinder orientation.
The camera sensor on Android devices might be in a different orientation
than the device natural orientation. There is no API in Qt to know about
the camera orientation, so correcting the viewfinder orientation is not
possible without making guesses. This patch makes sure the viewfinder
orientation always matches the device natural orientation. For example,
if the camera is mounted in landscape, and the device natural
orientation is portrait, the viewfinder will automatically be rotated 90
degrees counter-clockwise.
Task-number: QTBUG-35086
Change-Id: Ia890872971d72657debe709f61edba27d09dec65
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/plugins/android/src/wrappers')
-rw-r--r-- | src/plugins/android/src/wrappers/jcamera.cpp | 12 | ||||
-rw-r--r-- | src/plugins/android/src/wrappers/jcamera.h | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/android/src/wrappers/jcamera.cpp b/src/plugins/android/src/wrappers/jcamera.cpp index 2d42ffbd6..e69cb554d 100644 --- a/src/plugins/android/src/wrappers/jcamera.cpp +++ b/src/plugins/android/src/wrappers/jcamera.cpp @@ -118,6 +118,7 @@ JCamera::JCamera(int cameraId, jobject cam) : QObject() , QJNIObjectPrivate(cam) , m_cameraId(cameraId) + , m_rotation(0) , m_hasAPI14(false) { if (isValid()) { @@ -205,6 +206,11 @@ int JCamera::getNativeOrientation() return m_info.getField<jint>("orientation"); } +void JCamera::setDisplayOrientation(int degrees) +{ + callMethod<void>("setDisplayOrientation", "(I)V", degrees); +} + QSize JCamera::getPreferredPreviewSizeForVideo() { if (!m_parameters.isValid()) @@ -612,10 +618,16 @@ void JCamera::setRotation(int rotation) if (!m_parameters.isValid()) return; + m_rotation = rotation; m_parameters.callMethod<void>("setRotation", "(I)V", rotation); applyParameters(); } +int JCamera::getRotation() const +{ + return m_rotation; +} + QList<QSize> JCamera::getSupportedPictureSizes() { QList<QSize> list; diff --git a/src/plugins/android/src/wrappers/jcamera.h b/src/plugins/android/src/wrappers/jcamera.h index 464ca3cb2..7c47ec7a2 100644 --- a/src/plugins/android/src/wrappers/jcamera.h +++ b/src/plugins/android/src/wrappers/jcamera.h @@ -82,6 +82,8 @@ public: CameraFacing getFacing(); int getNativeOrientation(); + void setDisplayOrientation(int degrees); + QSize getPreferredPreviewSizeForVideo(); QList<QSize> getSupportedPreviewSizes(); @@ -136,6 +138,7 @@ public: void setWhiteBalance(const QString &value); void setRotation(int rotation); + int getRotation() const; QList<QSize> getSupportedPictureSizes(); void setPictureSize(const QSize &size); @@ -174,6 +177,7 @@ private: QJNIObjectPrivate m_parameters; QSize m_previewSize; + int m_rotation; bool m_hasAPI14; }; |