android - Rounded Corner doesn't work on openFileInput Bitmap -


the rounded corner code works on both volley networkimageview , resource. doesn't work on bitmap applicationcontext. here below code.

public class imageviewutils {     public static bitmap getroundedcornerbitmap(bitmap bitmap, int pixels) {     bitmap output = bitmap.createbitmap(bitmap.getwidth(),             bitmap.getheight(), bitmap.config.argb_8888);     canvas canvas = new canvas(output);      final int color = 0xff424242;     final paint paint = new paint();     final rect rect = new rect(0, 0, bitmap.getwidth(), bitmap.getheight());     final rectf rectf = new rectf(rect);      paint.setantialias(true);     canvas.drawargb(0, 0, 0, 0);     paint.setcolor(color);     canvas.drawroundrect(rectf, pixels, pixels, paint);      paint.setxfermode(new porterduffxfermode(porterduff.mode.src_in));     canvas.drawbitmap(bitmap, rect, rect, paint);      return output;     } }   public class fragment{      ......      imageview.setimagebitmap(imageviewutils.getroundedcornerbitmap(((appcontext) getactivity().getapplicationcontext()).getuserphoto(), 10); // rounded corner doesn't work.       imageview.setimagebitmap(imageviewutils.getroundedcornerbitmap(bitmapfactory.decoderesource(getactivity().getresources(), r.drawable.ic_avatar), 10); // rounded corner works.      ...... }    public class appcontext extends application {     ......     // bitmap of photo.     public bitmap getuserphoto(){          fileinputstream in = null;         try {             in = openfileinput(key_user_photo_file_name);             return bitmapfactory.decodestream(in);         } catch (ioexception e) {             log.d(tag, e.tostring());             return bitmapfactory.decoderesource(getresources(),r.drawable.ball);         } {             if(in != null) try {                 in.close();             } catch (ioexception e) {                 e.printstacktrace();             }         }      }     ...... } 

below layout of imageview

        <imageview         android:id="@+id/logo"         android:src="@drawable/ball"         android:contentdescription="@string/title_activity_profile"         android:padding="4dp"         android:layout_height="@dimen/touchable_height_15"         android:layout_width="@dimen/touchable_width_15"         android:scaletype="fitxy" /> 

the weird thing works on resource doesn't work on bitmap object. bother me 4 hours. can shed light?

possible image resolution high, 10px round not visible, try higher value of corner radius - should make visible.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -