diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/winrt/qwinrtcameracontrol.cpp | 16 | ||||
-rw-r--r-- | src/plugins/winrt/qwinrtimageencodercontrol.cpp | 9 |
2 files changed, 18 insertions, 7 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); diff --git a/src/plugins/winrt/qwinrtimageencodercontrol.cpp b/src/plugins/winrt/qwinrtimageencodercontrol.cpp index 7ea851b77..2aed5f8a6 100644 --- a/src/plugins/winrt/qwinrtimageencodercontrol.cpp +++ b/src/plugins/winrt/qwinrtimageencodercontrol.cpp @@ -105,8 +105,15 @@ void QWinRTImageEncoderControl::applySettings() if (d->imageEncoderSetting.codec().isEmpty()) d->imageEncoderSetting.setCodec(QStringLiteral("jpeg")); + if (d->supportedResolutions.isEmpty()) + return; + QSize requestResolution = d->imageEncoderSetting.resolution(); - if (d->supportedResolutions.isEmpty() || d->supportedResolutions.contains(requestResolution)) + if (!requestResolution.isValid()) { + d->imageEncoderSetting.setResolution(d->supportedResolutions.last()); + return; + } + if (d->supportedResolutions.contains(requestResolution)) return; // Find closest resolution from the list |