How can I resize a picture before displaying it in a view with Android Universal Image Loader? -


i applied universal image loader library (1.8.3 version) app, , i'm trying resize image before displaying in gridview item (because sometime image big cache in memory.)

here trying:

... bitmapfactory.options resizeoptions = new bitmapfactory.options(); resizeoptions.insamplesize = 3; // decrease size 3 times resizeoptions.inscaled = true;  options = new displayimageoptions.builder() .showstubimage(r.drawable.blank) .showimageforemptyuri(r.drawable.no_image) .cacheinmemory() .cacheondisc() .decodingoptions(resizeoptions) .build(); ... 

this code doesn't make image 3 times smaller reason.

does have better way resize image specified density?

read java docs attentively:

options.insamplesize of incoming options not considered. library calculate appropriate sample size according imagescaletype(...) options.

also imagesizeutil.definetargetsizeforview(imageview imageview, int maximagewidth, int maximageheight) defines target size image:

size defined target view parameters, configuration parameters or device display dimensions. size computing algorithm:

  1. get actual drawn getwidth() , getheight() of view. if view haven't drawn yet go step #2.
  2. get layout_width , layout_height. if both of them haven't exact value go step #3.
  3. get maxwidth , maxheight. if both of them not set go step #4.
  4. get maximagewidth param (maximagewidthformemorycache) , maximageheight param (maximageheightformemorycache). if both of them not set (equal 0) go step #5.
  5. get device screen dimensions.

uil defines result bitmap size according imagescaletype , targetsize (and imageview's scaletype).


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -