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 accordingimagescaletype(...)
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:
- get actual drawn
getwidth()
,getheight()
of view. if view haven't drawn yet go step #2.- get
layout_width
,layout_height
. if both of them haven't exact value go step #3.- get
maxwidth
,maxheight
. if both of them not set go step #4.- get
maximagewidth
param (maximagewidthformemorycache) ,maximageheight
param (maximageheightformemorycache). if both of them not set (equal 0) go step #5.- get device screen dimensions.
uil defines result bitmap size according imagescaletype
, targetsize
(and imageview
's scaletype).
Comments
Post a Comment