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>
This commit is contained in:
committed by
The Qt Project
parent
d2b0a345ab
commit
60607544e1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user