0

Looking to resize six images I download from the size of 1200x1200 to just 1024x1024 without having the outOfMemory error. So far using the Bitmap.createScaledBitmap(src, dstWidth, dstHeight, filter) cause the OOM problems. and scaling it using the BitmapFactory.options and specifying the inSampleSize best can get me is 600x600 size image.

Is there any solution to scale the images to exactly 1024x1024 or there isn't ?

and a general question why we always have Bitmap problems in android can't they fix the garbage collector to collect all unused bitmaps ?

Kara
  • 6,115
  • 16
  • 50
  • 57
Driss Bounouar
  • 3,182
  • 2
  • 32
  • 49
  • possible duplicate of [How to Resize a Bitmap in Android?](http://stackoverflow.com/questions/4837715/how-to-resize-a-bitmap-in-android) – g00dy Jul 01 '13 at 13:33
  • @g00dy not a duplicate simply because the simple solutions giving there all give OOM error. So i'm looking for a different solution! – Driss Bounouar Jul 03 '13 at 09:35

1 Answers1

0

Where is the picture located? If it's inside the mdpi folder try to put it inside the hdpi or xhdpi. This solved my problem once. I guess Android also tries to resize the image so this causes out of memory errors.

C.d.
  • 9,932
  • 6
  • 41
  • 51
  • Android will resize the image in the res file based on the difference between the resource folder dpi class and the actual device screen density. If you don't want Android to resize it just put it in the /drawable/ folder – Mario Lenci Jul 01 '13 at 13:37
  • hey @C.d. the pictures are located in the SdCard not in the drawable folder...And I think you didn't get my question I want to resize a picture from 1200x1200 to 1024x1024 located in the SdCard and i would love to avoid the use `createScaledBitmap` method directly as it will surely cause the OOM error. – Driss Bounouar Jul 03 '13 at 09:38
  • Sorry I thought you were directly fetching them from the drawable folder. In that case, I don't have anything on my mind about the out of memory error. – C.d. Jul 03 '13 at 12:03