List of usage examples for android.support.v4.graphics.drawable RoundedBitmapDrawable setCornerRadius
public void setCornerRadius(float f)
From source file:Main.java
public static RoundedBitmapDrawable getRoundedBitmapDrawable(Resources res, Bitmap src) { RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(res, src); dr.setCornerRadius(5); return dr;/*w w w.j av a 2s .c o m*/ }
From source file:com.ahmadrosid.lib.baseapp.helper.ImageViewHelper.java
public static void createRounded(Context context, int imgRes, ImageView imageView) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), imgRes); RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); rounded.setCornerRadius(bitmap.getWidth()); imageView.setImageDrawable(rounded); }
From source file:com.gm.common.util.DrawableUtils.java
public static Drawable roundedBitmap(Context context, Bitmap bitmap) { RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); circleDrawable.getPaint().setAntiAlias(true); circleDrawable.setCircular(true);/*www . j ava 2 s . com*/ circleDrawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); return circleDrawable; }
From source file:com.fjoglar.etsitnoticias.utils.UiUtils.java
/** * Create a circular drawable from a resource drawable id. * * @param context Need to get the resources * @param resId Drawable's id.//from w ww .ja va 2 s. c o m * * @return RoundedBitmapDrawable */ public static RoundedBitmapDrawable getCircleBitmapDrawable(Context context, int resId) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId); RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setCornerRadius(Math.max(bitmap.getWidth() / 2, bitmap.getHeight() / 2)); drawable.setAntiAlias(true); return drawable; }
From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.ImageViewSetters.java
@BindingAdapter(value = { "imageUrl", "cornerRadius" }, requireAll = false) public static void setImageUrl(final ImageView imageView, String url, final float cornerRadius) { if (Strings.isNullOrEmpty(url)) { imageView.setImageBitmap(null);//from ww w .java2s . c o m } else if (url.endsWith("gif")) { Glide.with(imageView.getContext()).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(imageView); } else { if (cornerRadius > 0) { Glide.with(imageView.getContext()).load(url).asBitmap().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(imageView.getContext().getResources(), resource); circularBitmapDrawable.setCornerRadius(cornerRadius); imageView.setImageDrawable(circularBitmapDrawable); } }); } else { Glide.with(imageView.getContext()).load(url).into(imageView); } } }
From source file:com.tr4android.support.extension.widget.CircleImageView.java
/** * Helper for creating a circle bitmap drawable using the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} * * @param bitmap The bitmap which should be converted to a circle bitmap drawable * @return the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} containing the bitmap *///ww w. j a v a 2 s . c o m public static RoundedBitmapDrawable getCircleBitmapDrawable(Context context, Bitmap bitmap) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setCornerRadius(Math.max(bitmap.getWidth() / 2, bitmap.getHeight() / 2)); drawable.setAntiAlias(true); return drawable; }
From source file:com.qhn.bhne.xhmusic.utils.MyUtils.java
public static void setCircleIMG(final Activity activity, Object resImageId, final ImageView userPhoto) { if (resImageId instanceof String && TextUtils.isEmpty((String) resImageId)) { Toast.makeText(activity, "?", Toast.LENGTH_SHORT).show(); return;/* w w w. j a v a 2 s . c o m*/ } if (resImageId instanceof Integer && (Integer) resImageId == 0) { Toast.makeText(activity, "?", Toast.LENGTH_SHORT).show(); return; } if (userPhoto == null) { Toast.makeText(activity, "", Toast.LENGTH_SHORT).show(); return; } Glide.with(activity).load(resImageId).asBitmap().placeholder(R.drawable.ic_placeholder).centerCrop() .into(new BitmapImageViewTarget(userPhoto) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(activity.getResources(), resource); //circularBitmapDrawable.setCircular(true); circularBitmapDrawable.setCornerRadius(2); userPhoto.setImageDrawable(circularBitmapDrawable); } }); }
From source file:net.simno.klingar.ui.widget.CircleImageViewTarget.java
@Override public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(bitmap, glideAnimation); RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(view.getResources(), bitmap); rounded.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight())); rounded.setAntiAlias(true);//from w w w . j a va 2 s . c o m view.setImageDrawable(rounded); }
From source file:com.yoloo.android.util.glide.transfromation.RoundedCornersTransformation2.java
@Override public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) { Bitmap source = resource.get();/* w w w .j a va 2 s .co m*/ RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), source); drawable.setCornerRadius(radius); return BitmapResource.obtain(drawable.getBitmap(), bitmapPool); }
From source file:org.opensilk.common.ui.widget.CircleImageView.java
protected RoundedBitmapDrawable createRoundDrawable(Bitmap bm) { RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), bm); d.setCornerRadius(radius); return d;/* ww w . j a v a 2 s .c om*/ }