void PhotoBomberApp::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); }
void ApplicationUIBase::set_aspect_ratio(bb::cascades::multimedia::Camera *camera, const float aspect) { #define DELTA(x, y) (x>y?(x-y):(y-x)) CameraSettings camsettings; camera->getSettings(&camsettings); QVariantList reslist = camera->supportedCaptureResolutions(CameraMode::Photo); 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); } } camera->applySettings(&camsettings); }