summaryrefslogtreecommitdiffstats
path: root/src/plugins/winrt/qwinrtcameracontrol.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-04-10 12:42:28 +0200
committerLiang Qi <liang.qi@qt.io>2019-04-10 12:42:28 +0200
commit82fdc8913483dd352ae2c326dd358fe9ff8f3f66 (patch)
tree5bc321569aa2ba0821a04b0b439edd549ded6512 /src/plugins/winrt/qwinrtcameracontrol.cpp
parentf787689e74dee63c55f2731683a4ede752fd9e44 (diff)
parentc8716f68feb5a38473cbd54972b9a9f095e9e24d (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp Done-with: Val Doroshchuk <valentyn.doroshchuk@qt.io> Change-Id: I745dd948c1e98180115f85c17bef802351bbdb6b
Diffstat (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp')
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp
index c00f65624..ede3f6b04 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameracontrol.cpp
@@ -1398,6 +1398,10 @@ HRESULT QWinRTCameraControl::onInitializationCompleted(IAsyncAction *, AsyncStat
&captureResolutions);
RETURN_HR_IF_FAILED("Failed to find a suitable video format");
+ std::sort(captureResolutions.begin(), captureResolutions.end(), [](QSize size1, QSize size2) {
+ return size1.width() * size1.height() < size2.width() * size2.height();
+ });
+
// Set capture resolutions.
d->imageEncoderControl->setSupportedResolutionsList(captureResolutions.toList());
const QSize captureResolution = d->imageEncoderControl->imageSettings().resolution();
@@ -1412,17 +1416,17 @@ HRESULT QWinRTCameraControl::onInitializationCompleted(IAsyncAction *, AsyncStat
Q_ASSERT_SUCCEEDED(hr);
// Set preview resolution.
- QVector<QSize> filtered;
+ QSize maxSize;
const float captureAspectRatio = float(captureResolution.width()) / captureResolution.height();
for (const QSize &resolution : qAsConst(previewResolutions)) {
const float aspectRatio = float(resolution.width()) / resolution.height();
- if (qAbs(aspectRatio - captureAspectRatio) <= ASPECTRATIO_EPSILON)
- filtered.append(resolution);
+ if ((qAbs(aspectRatio - captureAspectRatio) <= ASPECTRATIO_EPSILON)
+ && (maxSize.width() * maxSize.height() < resolution.width() * resolution.height())) {
+ maxSize = resolution;
+ }
}
- std::sort(filtered.begin(), filtered.end(),
- [](QSize size1, QSize size2) { return size1.width() * size1.height() < size2.width() * size2.height(); });
- const QSize &viewfinderResolution = filtered.first();
+ const QSize &viewfinderResolution = maxSize;
const quint32 viewfinderResolutionIndex = quint32(previewResolutions.indexOf(viewfinderResolution));
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_MediaProperties_MediaEncodingProfile).Get(),
&d->encodingProfile);