Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void camerautils::selectAspectRatio(bb::cascades::multimedia::Camera *camera, const float aspect)
- {
- CameraSettings camsettings;
- camera->getSettings(&camsettings);
- // Get a list of supported resolutions.
- QVariantList reslist = camera->supportedCaptureResolutions(CameraMode::Photo);
- // Find the closest match to the aspect parameter
- for (int i = 0; i < reslist.count(); i++) {
- QSize res = reslist[i].toSize();
- qDebug() << "supported resolution: " << res.width() << "x" << res.height();
- // Check for w:h or h:w within 5px margin of error...
- if ((DELTA(res.width() * aspect, res.height()) < 5)
- || (DELTA(res.width(), res.height() * aspect) < 5)) {
- qDebug() << "picking resolution: " << res.width() << "x" << res.height();
- camsettings.setCaptureResolution(res);
- break;
- }
- }
- // Update the camera setting
- camera->applySettings(&camsettings);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement