Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
5.5.1, 5.6.0 Beta
-
None
-
Xiaomi Mi2S Android 5.0.2
-
d7d31d63db5f0029a4a5e24d998601baee8bade0
Description
This commit not solves problem completely. Example: there are cameras with capture resolution 4208x3120 (ratio 1.348). Difference between ratio of 1280x960(1.333) is 0.015. For such cameras we can not see preview. But increasing value 0.01 its not good way.
In function adjustViewfinderSize I suggest to use closest viewfinder resolution if any. Is this right to doing so?
... if (m_captureMode.testFlag(QCamera::CaptureVideo) && m_camera->getPreferredPreviewSizeForVideo().isEmpty()) { // According to the Android doc, if getPreferredPreviewSizeForVideo() returns null, it means // the preview size cannot be different from the capture size adjustedViewfinderResolution = captureSize; } else { // search for viewfinder resolution with the same aspect ratio const qreal aspectRatio = qreal(captureSize.width()) / qreal(captureSize.height()); QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes(); qreal minAspectDiff = 1; QSize closestResolution; for (int i = previewSizes.count() - 1; i >= 0; --i) { const QSize &size = previewSizes.at(i); const qreal sizeAspect = qreal(size.width()) / size.height(); if (qFuzzyCompare(aspectRatio, sizeAspect)) { adjustedViewfinderResolution = size; break; } else if (minAspectDiff > qAbs(sizeAspect - aspectRatio)) { closestResolution = size; minAspectDiff = qAbs(sizeAspect - aspectRatio); } } if (!adjustedViewfinderResolution.isValid()) { qWarning("Cannot find a viewfinder resolution matching the capture aspect ratio."); if (closestResolution.isValid()) { adjustedViewfinderResolution = closestResolution; qWarning("Using closest viewfinder resolution."); } else { return; } } } ...