out of memory error while decoding the image with sample size after decoding it within bounds
<p>I am beginner in android. While decoding the images ( of size 1600x1200 ) from SD card one by one i am getting the below error. After decoding the bitmap i have to apply the animation for the imageview to play the image like slide show in full screen. i am using the below calculation for getting samplesize after decoding the bitmap in bounds.</p>

<pre><code>while (true) {
    if (width_tmp / 2 &lt; REQUIRED_WIDTH || height_tmp / 2 &lt; REQUIRED_HEIGHT )
        break;
    width_tmp /= 2;
    height_tmp /= 2;
    scale *= 2;
}
</code></pre>

<p>Can anyone please help me to solve this issue. </p>

<pre><code>Error:
11-09 13:39:15.100: E/DhcpStateMachine(424): DHCP failed on wlan0: Timed out waiting for DHCP to finish
11-09 13:39:15.300: E/WifiStateMachine(424): IP configuration failed
11-09 13:39:32.840: E/dalvikvm-heap(2511): Out of memory on a 20155408-byte allocation.
11-09 13:39:32.870: E/AndroidRuntime(2511): FATAL EXCEPTION: AsyncTask #1
11-09 13:39:32.870: E/AndroidRuntime(2511): java.lang.RuntimeException: An error occured while executing doInBackground()
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.lang.Thread.run(Thread.java:856)
11-09 13:39:32.870: E/AndroidRuntime(2511): Caused by: java.lang.OutOfMemoryError
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:301)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at com.example.testproject1.Imgloader.loadImageFromSDCard(Imgloader.java:60)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at com.example.testproject1.Imgloader.access$0(Imgloader.java:50)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at com.example.testproject1.Imgloader$SDLoadImageTask.doInBackground(Imgloader.java:177)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at com.example.testproject1.Imgloader$SDLoadImageTask.doInBackground(Imgloader.java:1)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-09 13:39:32.870: E/AndroidRuntime(2511):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-09 13:39:32.870: E/AndroidRuntime(2511):     ... 5 more
11-09 13:39:32.970: E/dalvikvm-heap(2511): Out of memory on a 20155408-byte allocation.
11-09 13:39:46.530: E/DhcpStateMachine(424): DHCP failed on wlan0: Timed out waiting for DHCP to finish
11-09 13:39:46.749: E/WifiStateMachine(424): IP configuration failed
11-09 13:40:18.180: E/DhcpStateMachine(424): DHCP failed on wlan0: Timed out waiting for DHCP to finish
11-09 13:40:18.399: E/WifiStateMachine(424): IP configuration failed
11-09 13:40:18.399: E/WifiStateMachine(424): Failed 10 times, Disabling 3
</code></pre>
