Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal image loader roundedBitmapDisplayer issues

I'm using latest universal-image-loader-1.9.2-SNAPSHOT-with-sources.jar file. Its working fine. I want to change image to round(Circle). I have used following display options.

             DisplayImageOptions userimgoptions = new DisplayImageOptions.Builder()
                           .displayer(new RoundedBitmapDisplayer(35))
                           .showImageOnLoading(android.R.color.transparent)
                           .showImageForEmptyUri(R.drawable.picture_info_profile_img)
                           .showImageOnFail(R.drawable.picture_info_profile_img)
                           .cacheInMemory(true).cacheOnDisc(true)
                           .bitmapConfig(Bitmap.Config.RGB_565).build();

its not working for some images. I have tested this into low and high resolution its not working.

Note : In my xml Imageview height and with(55 * 55).

enter image description hereenter image description hereenter image description hereenter image description here

please kindly help me how to resolve this issue. i cant resolve this issue.

Thanks,

like image 538
Murali Ganesan Avatar asked Feb 06 '14 12:02

Murali Ganesan


3 Answers

If you want a circular image you can change .displayer(new RoundedBitmapDisplayer(25)) to .displayer(new RoundedBitmapDisplayer(1000)) which worked for me.

like image 82
timbillstrom Avatar answered Nov 16 '22 00:11

timbillstrom


If you want a rounded image you need to set the rounded bitmap displayer to the radius of the image which in your case is 1/2 55 or 27.5

DisplayImageOptions userimgoptions = new DisplayImageOptions.Builder()
                       .displayer(new RoundedBitmapDisplayer((int) 27.5f))
                       .showImageOnLoading(android.R.color.transparent)
                       .showImageForEmptyUri(R.drawable.picture_info_profile_img)
                       .showImageOnFail(R.drawable.picture_info_profile_img)
                       .cacheInMemory(true).cacheOnDisc(true)
                       .bitmapConfig(Bitmap.Config.RGB_565).build();

But it's probably not a good idea to hard code that, I would change the config when you actually get the bitmap and calculate the width.

like image 36
Brian Avatar answered Nov 16 '22 01:11

Brian


I've found the RoundedBitmpDisplayer to be pretty slow even with the latest rewrite. By far the fastest way I've found to get a Rounded corners consistently is to use RoundedImageView. https://github.com/vinc3m1/RoundedImageView You can pass that view into UIL and the view will take care of rounding the corners for you. You just specify the radius you want.

like image 22
kingargyle Avatar answered Nov 16 '22 00:11

kingargyle