android - Can I use a custom decoder to downsample an image before loading it in Glide? -


i'm trying make panorama viewer takes 360 degree picture , map cylinder. i've gotten part right, based on modification of md360player4android library, , i'm using glide instead of picasso.

however, problem right when try load 360 picture (which 2500-3000px x 19168px in size), image fails load oom exception.

the glide method used results in oom:

glide.with(getactivity())     .load(path)     .asbitmap()     .override((int)(width/2.4f), (int)(height/2.4f))     .fitcenter()     .diskcachestrategy(diskcachestrategy.none)     .into(commonsimpletarget); 

currently have method instead:

new asynctask<void, void, bitmap>() {     @override     protected bitmap doinbackground(void... params) {         //downsampling image         opts.insamplesize = 4;         opts.injustdecodebounds = false;         try {             bitmap res = bitmapfactory.decodestream(getactivity().getcontentresolver().openinputstream(uri), null, opts);             if(height > width){                 res = bitmap.createscaledbitmap(res, (int)(width * callback.getmaxtexturesize() / height), callback.getmaxtexturesize(), true);             } else {                 res = bitmap.createscaledbitmap(res, callback.getmaxtexturesize(), (int)(height * callback.getmaxtexturesize() / width), true);             }             matrix matrix = new matrix();             matrix.postrotate(90);             res = bitmap.createbitmap(res , 0, 0, res .getwidth(), res.getheight(), matrix, true);             return res;         } catch(filenotfoundexception fof) {             fof.printstacktrace();             return null;         }     }     @override     protected void onpostexecute(bitmap bitmap) {         super.onpostexecute(bitmap);         //code load image viewer     } }.execute(); 

i'm still using glide 3.8.0, , heard glide allows option of custom decoders downsample image when it's decoded inputstream, don't have see glide trying load 3040x19168 image memory , net me oom , instead load downsampled version of instead.

so, basically, question is, can put code in doinbackground section of above asynctask glide custom decoder?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -