title: Bad image quality after resizing/scaling bitmap
body: <p>I'm writing a card game and need my cards to be different sizes in different circumstances. I am storing my images as bitmaps so that they can be quickly drawn and redrawn (for animation).</p>
  
  <p>My problem is that no matter how I try and scale my images (whether through a matrix.postScale, a matrix.preScale, or a createScaledBitmap function) they always come out pixelated and blurry. I know that its the scaling thats causing the problem because the images look perfect when drawn without resizing. </p>
  
  <p>I have worked through every solution described in these two threads:<br>
  <a href="https://stackoverflow.com/questions/2041207/android-quality-of-the-images-resized-in-runtime">android quality of the images resized in runtime</a><br>
  <a href="https://stackoverflow.com/questions/4231817/quality-problems-when-resizing-an-image-at-runtime">quality problems when resizing an image at runtime</a></p>
  
  <p>but still haven't gotten anywhere. </p>
  
  <p>I store my bitmaps (into a hashmap) with this code:</p>
  
  <pre><code>cardImages = new HashMap&lt;Byte, Bitmap&gt;();
  cardImages.put(GameUtil.hearts_ace, BitmapFactory.decodeResource(r, R.drawable.hearts_ace));
  </code></pre>
  
  <p>and draw them with this method (in a Card class):</p>
  
  <pre><code>public void drawCard(Canvas c)
  {
      //retrieve the cards image (if it doesn't already have one)
      if (image == null)
          image = Bitmap.createScaledBitmap(GameUtil.cardImages.get(ID), 
              (int)(GameUtil.standardCardSize.X*scale), (int)(GameUtil.standardCardSize.Y*scale), false);
  
          //this code (non-scaled) looks perfect
          //image = GameUtil.cardImages.get(ID);
  
      matrix.reset();
      matrix.setTranslate(position.X, position.Y);
  
      //These methods make it look worse
      //matrix.preScale(1.3f, 1.3f);
      //matrix.postScale(1.3f, 1.3f);
  
      //This code makes absolutely no difference
      Paint drawPaint = new Paint();
      drawPaint.setAntiAlias(false);
      drawPaint.setFilterBitmap(false);
      drawPaint.setDither(true);
  
      c.drawBitmap(image, matrix, drawPaint);
  }
  </code></pre>
  
  <p>Any insight would be greatly appreciated. Thanks</p>