title: How to resize a bitmap eficiently and with out losing quality in android
body: <p>I have a <code>Bitmap</code> with a size of <code>320x480</code> and I need to stretch it on different device screens, I tried using this:</p>
  
  <pre><code>Rect dstRect = new Rect();
  canvas.getClipBounds(dstRect);
  canvas.drawBitmap(frameBuffer, null, dstRect, null);
  </code></pre>
  
  <p>it works, the image fills the whole screen like I wanted but the image is pixelated and it looks bad. Then I tried :</p>
  
  <pre><code>float scaleWidth = (float) newWidth / width;
  float scaleHeight = (float) newHeight / height;
  Matrix matrix = new Matrix();
  matrix.postScale(scaleWidth, scaleHeight);
  Bitmap resizedBitmap = Bitmap.createBitmap(frameBuffer, 0, 0,
                  width, height, matrix, true);
  canvas.drawBitmap(resizedBitmap, 0, 0, null);
  </code></pre>
  
  <p>this time it looks perfect, nice and smooth, but this code has to be in my main game loop and creating <code>Bitmap</code>s every iteration makes it very slow. How can I resize my image so it doesn't get pixelated and gets done fast?</p>
  
  <p><strong>FOUND THE SOLUTION:</strong></p>
  
  <pre><code>Paint paint = new Paint();
  paint.setFilterBitmap();
  canvas.drawBitmap(bitmap, matrix, paint);
  </code></pre>