title: Android loading of large bitmaps
body: <p>I'm making an Android app and I need to load an image (bitmap) in a cavas and resize it using the "pinch zoom" gesture. When the image is over a certain size, however, the application crashes (OutOfMemory exception). How do I optimize the loading and manipulation of the image?</p>
  
  <p>To load the image I use:</p>
  
  <pre><code>BitmapFactory.decodeResource (ctx.getResources (), R.drawable.image)
  </code></pre>
  
  <p>To draw it:</p>
  
  <pre><code>imgCanvas.drawBitmap (image, posX, posY, null), 
  </code></pre>
  
  <p>To change its size:</p>
  
  <pre><code>Bitmap.createScaledBitmap (originalBitmap, neww, NEWH, true);
  </code></pre>