java - how to decode byte array to bitmap without OOM Exception -


i stuck in out of memory. i’m trying load image byte array ever i’ve done wouldn’t work. bitmap decoder error guess. these code :

       string password = prefs.getstring("bookkey", "");        bufferedinputstream buf = new bufferedinputstream(new fileinputstream(file));        buf.read(bytes, 0, bytes.length);        buf.close();        byte[] bytesdecrpy = decrypt(bytes, password);         bitmapfactory.options options = new bitmapfactory.options();        options.indither = true;        options.injustdecodebounds = false;        options.inpreferredconfig = bitmap.config.argb_8888;        options.intempstorage = new byte[32 * 1024];        options.inbitmap = bitmapfactory.decodebytearray(bytesdecrpy, 0,                bytesdecrpy.length, options);         bm = bitmap.createbitmap(options.outwidth,                options.outheight, bitmap.config.argb_8888);         imageview.setimage(imagesource.bitmap(bm)); 

i read byte array encrypt png device file i having problem when create bitmap bitmap variable. still couldn’t run 2 days. if can me solve problem great. thank you.

edit

i've tried decode byte array bitmap problem never changed i've started problem in decode then

       bm = bitmapfactory.decodebytearray(bytesdecrpy, 0,                bytesdecrpy.length, options); 

this can cause oom exception if bitmap large use background thread decode , load image in container or use caching technique explained in https://developer.android.com/training/displaying-bitmaps/index.html


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -