summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig.qnx@kdab.com>2013-02-08 17:38:25 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-12 08:50:00 +0100
commit60607544e16eda72d0896f4699e492486b9c7a86 (patch)
tree4f18e0e38996804aa18ab8a1d9d4658a5eef03a4
parentd2b0a345ab65eca43d9b6c3b3b0020abb8b115e7 (diff)
Blackberry: Fix orientation of taken photos
Ensure that the taken photos are always upright. As long as the QCamera API does not provide information about the native orientation of the camera, we have to do the rotation inside the BBCamera plugin. Change-Id: Iebb04a5417274c2baee5e944dadf10fc706484d9 Reviewed-by: Bernd Weimer <bweimer@rim.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-rw-r--r--src/plugins/blackberry/camera/bbcamerasession.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/blackberry/camera/bbcamerasession.cpp b/src/plugins/blackberry/camera/bbcamerasession.cpp
index be352b197..0ab3ab7db 100644
--- a/src/plugins/blackberry/camera/bbcamerasession.cpp
+++ b/src/plugins/blackberry/camera/bbcamerasession.cpp
@@ -807,7 +807,7 @@ void BbCameraSession::handleVideoViewFinderData(camera_buffer_t *buffer)
{
QTransform transform;
- transform.rotate(360 - m_nativeCameraOrientation);
+ transform.rotate(m_nativeCameraOrientation);
const QImage frame = convertFrameToImage(buffer).transformed(transform);
@@ -829,8 +829,21 @@ void BbCameraSession::updateReadyForCapture()
emit readyForCaptureChanged(isReadyForCapture());
}
-void BbCameraSession::imageCaptured(int requestId, const QImage &image, const QString &fileName)
+void BbCameraSession::imageCaptured(int requestId, const QImage &rawImage, const QString &fileName)
{
+ QTransform transform;
+
+ // subtract out the native rotation
+ transform.rotate(m_nativeCameraOrientation);
+
+ // subtract out the current device orientation
+ if (m_device == cameraIdentifierRear())
+ transform.rotate(360 - m_orientationHandler->orientation());
+ else
+ transform.rotate(m_orientationHandler->orientation());
+
+ const QImage image = rawImage.transformed(transform);
+
// Generate snap preview as downscaled image
{
QSize previewSize = image.size();
@@ -1139,7 +1152,7 @@ void BbCameraSession::applyConfiguration()
CAMERA_IMGPROP_WIDTH, viewfinderResolution.width(),
CAMERA_IMGPROP_HEIGHT, viewfinderResolution.height(),
CAMERA_IMGPROP_FORMAT, CAMERA_FRAMETYPE_NV12,
- CAMERA_IMGPROP_ROTATION, m_nativeCameraOrientation);
+ CAMERA_IMGPROP_ROTATION, 360 - m_nativeCameraOrientation);
if (result != CAMERA_EOK) {
qWarning() << "Unable to apply photo viewfinder settings:" << result;
@@ -1171,7 +1184,7 @@ void BbCameraSession::applyConfiguration()
CAMERA_IMGPROP_WIDTH, photoResolution.width(),
CAMERA_IMGPROP_HEIGHT, photoResolution.height(),
CAMERA_IMGPROP_JPEGQFACTOR, jpegQuality,
- CAMERA_IMGPROP_ROTATION, m_nativeCameraOrientation);
+ CAMERA_IMGPROP_ROTATION, 360 - m_nativeCameraOrientation);
if (result != CAMERA_EOK) {
qWarning() << "Unable to apply photo settings:" << result;
@@ -1204,7 +1217,7 @@ void BbCameraSession::applyConfiguration()
const camera_error_t result = camera_set_videovf_property(m_handle,
CAMERA_IMGPROP_WIDTH, viewfinderResolution.width(),
CAMERA_IMGPROP_HEIGHT, viewfinderResolution.height(),
- CAMERA_IMGPROP_ROTATION, m_nativeCameraOrientation);
+ CAMERA_IMGPROP_ROTATION, 360 - m_nativeCameraOrientation);
if (result != CAMERA_EOK) {
qWarning() << "Unable to apply video viewfinder settings:" << result;