title: How to solve distorted image issue in android custom camera for galaxy S4
body: <p>I am working on custom camera application for android. The problem is that the camera capture and showing preview good in other devices (example Samsung Galaxy S3) , but It shows distorted 
  image on Galaxy s4, Can any one help me?? </p>
  
  <p>My code for Picturesize() method is as follows:</p>
  
  <pre><code>Camera.Size getBestPicturSize(int width, int height, Camera.Parameters parameters) {
          Camera.Size result=null;
          float dr = Float.MAX_VALUE;
          float ratio = (float)width/(float)height;
  
          for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
              float r = (float)size.width/(float)size.height;
              if( Math.abs(r - ratio) &lt; dr &amp;&amp; size.width &lt;= width &amp;&amp; size.height &lt;= height ) {
                  dr = Math.abs(r - ratio);
                  result = size;
              }
          }
  
          return result;
      }
  </code></pre>