Advertisement
deimos

Untitled

Jun 4th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. void camerautils::selectAspectRatio(bb::cascades::multimedia::Camera *camera, const float aspect)
  2. {
  3. CameraSettings camsettings;
  4. camera->getSettings(&camsettings);
  5.  
  6. // Get a list of supported resolutions.
  7. QVariantList reslist = camera->supportedCaptureResolutions(CameraMode::Photo);
  8.  
  9. // Find the closest match to the aspect parameter
  10. for (int i = 0; i < reslist.count(); i++) {
  11. QSize res = reslist[i].toSize();
  12. qDebug() << "supported resolution: " << res.width() << "x" << res.height();
  13.  
  14. // Check for w:h or h:w within 5px margin of error...
  15. if ((DELTA(res.width() * aspect, res.height()) < 5)
  16. || (DELTA(res.width(), res.height() * aspect) < 5)) {
  17. qDebug() << "picking resolution: " << res.width() << "x" << res.height();
  18. camsettings.setCaptureResolution(res);
  19. break;
  20. }
  21. }
  22.  
  23. // Update the camera setting
  24. camera->applySettings(&camsettings);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement