title: Saving large image to PNG
body: <p>I've just encontered a tough problem...</p>
  
  <p>Here's my story:</p>
  
  <p>My device is Samsung Galaxy Note, normally, it takes pictures at a resolution of <strong>3264 * 2448</strong> pixels. I love fine pictures when am tring to find detailed information, but here I hate it because it's huge to handle in Android. I can read and display an image of this big resolution, I need to draw lines on top of it, then I need to save both picture and lines to a png.
  My headache is that my Android always gives me <strong>Out of memery exception</strong>, when am trying to create a mutable bitmap like this:</p>
  
  <pre><code>    Bitmap bmp = Bitmap.createBitmap(3264, 2448, Config.RGB_565);
      Canvas cv = new Canvas(bmp);
      //draw a line and save and restore canvas
      // I found an alternative solution yet proven to be uncorrect:
      myImageView.setDrawingCacheEnabled(true);
      myImageView.buildDrawingCache(true);
      Bitmap bmp = myImageView.getDrawingCache();
      //save bmp to png
  </code></pre>
  
  <p>When the </p>
  
  <pre><code>bmp.width * bmp.height * 4 &gt; getScaledMaximumDrawingCacheSize()
  </code></pre>
  
  <p>exception jumps out. I've tested <code>myImageView.measure(...)</code> and <code>myImageView.layout(...)</code>, didn't work for me.
  (Things are fine, when I test the same code using smaller images)</p>
  
  <p>Any experts know how to kill this problem or throw a solution to me? Thanks!</p>