Android Error java.lang.OutOfMemoryError: bitmap size exceeds VM budget -


am getting exception error when loading images assets arraylist. error in log cat: e/androidruntime(2837): java.lang.outofmemoryerror: bitmap size exceeds vm budget

please 1 me this,thanks in advance

once, tried re-size image, i' having same problem, used below code, can modify yours,

public bitmap custom_sizedimage(string intent_data2) { options options = new options(); options.injustdecodebounds = true; bitmapfactory.decodefile(intent_data2, options); double samplesize = 0; boolean scalebyheight = math.abs(options.outheight - targetheight) >= math .abs(options.outwidth - targetwidth); if (options.outheight * options.outwidth * 2 >= 1638) { samplesize = scalebyheight ? options.outheight / targetheight : options.outwidth / targetwidth; samplesize = (int) math.pow(2d, math.floor(math.log(samplesize) / math.log(2d))); } options.injustdecodebounds = false; options.intempstorage = new byte[128]; while (true) { try { options.insamplesize = (int) samplesize; // here can decode process //mbitmap = bitmapfactory.decodefile(intent_data2, options); break; } catch (exception ex) { try { samplesize = samplesize * 2; } catch (exception ex1) { } } } return scaledbitmap; } 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -