title: How do I find a dimension of aspect ratio 4:3 which fits within a predetermined size?
body: <p>The problem here is I have a display window of size x by y, and I need to display an image inside the window without any scrolling, and to maintain the aspect ratio of 4:3. I have the following snippet of code:</p>
  
  <pre><code>// Lock the current height, calculate new width of the canvas and scale the viewport.
  // get width of the movie canvas
  qreal width = canvas_-&gt;width();
  
  // Find the height of the video
  qreal height = (width/4.0) * 3;
  
  // find original width and height for video to calculate scaling factor
  qreal videoWidth = movieData_-&gt;GetWidth();
  qreal videoHeight = movieData_-&gt;GetHeight();
  
  // calculate scaling factor
  qreal scaleFactorWidth = width/videoWidth;
  qreal scaleFactorHeight = height/videoHeight;
  </code></pre>
  
  <p>Of course, by using either the height, or the width as the 'anchor', one way or other the new image will cause scrolling (assuming the original image is larger than the window in the first place). How do I find a dimension of aspect ratio 4:3 which fits within a predetermined size?</p>
  
  <p><b>Edit</b>
  I would need to pass in a scale factor for both x and y to do the scaling</p>
  
  <pre><code>canvas_-&gt;scale(scaleFactorWidth, scaleFactorHeight);
  </code></pre>