Loosing quality when resizing screenshot android
<p>I have a "DrawView" screen where after the user draw a sign, I get the picture.</p>

<p>The problem is that the picture needs to be more or less 300 width, so, I need to resize the picture before saving it.</p>

<p>I resize the picture, but the resultant picture is with very bad quality(like pixelated).
This is my code:</p>

<pre><code>Bitmap b = drawView.getDrawingCache(true);
    File sdCard = Environment.getExternalStorageDirectory();

        //Here is where I try to get the width and the height with the same ratio...
    float ratio = (float)b.getHeight()/(float)b.getWidth();
    float height = 1;
    float width = 1;
    do{
        width++;
        height = height + (1*ratio);
    }while(height&lt;300 &amp;&amp; width&lt;300);

 //Here is where I resize the picture using the datas above
    Bitmap scaledBitmap = Bitmap.createScaledBitmap(b, (int)width, (int)height, true);

    File file = new File(sdCard, "/PaySys/"+String.valueOf(ticket.getId())+".jpg");

    FileOutputStream fos = null;

    try {
        fos = new FileOutputStream(file);
        scaledBitmap.compress(CompressFormat.JPEG, 100,fos);
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
        Log.e(TAG, e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, e.getLocalizedMessage());
    }
</code></pre>

<p>I added a picture to see the result picture given.....</p>

<p>Thanks a lot.<img src="http://i.stack.imgur.com/fCNIW.jpg" alt="enter image description here"></p>
