> How to open a high resolution png picture, the picture is > 4000x3000,but it crashed when it was decoded.
It depends what you want to do with the image. If it is a background for a game and you need it at this size, then you need to break it up and come up with a common tile preloading scheme. If you just want to display it on the screen you just need to downscale it a lot. I use this function in my code to try to get the biggest picture that can actually fit in memory, it's far from perfect, especially the fact that you actually can't feed the sampleSize with a float and have to go full integer at a time but it works without degraging the picture quality even when displayed on tablets : private Bitmap getDownsampledBitmapFromFile(String fileName, int sampleSize) { //Try to free up some memory System.gc(); System.runFinalization(); System.gc(); BitmapFactory.Options options=new BitmapFactory.Options();//reset object byte[] tempBuffer=new byte[8000]; options.inTempStorage = tempBuffer; options.inSampleSize=sampleSize; Bitmap downsampledBitmap = null; try { downsampledBitmap = BitmapFactory.decodeFile(fileNameToUpload, options); } catch (OutOfMemoryError e) { sampleSize ++; } return(downsampledBitmap); } I'm using it 'as is' because it worked for my purpose but if I had time I would run a benchmark to test if the double gc and finalization could not be moved to the catch and allow for a bigger size image to be computed without outofmemory exception. Yahel -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en