List of usage examples for android.support.v4.graphics.drawable RoundedBitmapDrawableFactory create
public static RoundedBitmapDrawable create(Resources resources, InputStream inputStream)
From source file:Main.java
public static RoundedBitmapDrawable getRoundedBitmapDrawable(Resources res, Bitmap src) { RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(res, src); dr.setCornerRadius(5);//w w w . j av a 2 s . c o m return dr; }
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);/*w ww. ja v a 2 s . c om*/ circleDrawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); return circleDrawable; }
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.ahmadrosid.lib.baseapp.helper.ImageViewHelper.java
public static void createRounded(Context context, String url, ImageView imageView) { try {/*w w w. j ava2s . c o m*/ Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(context.getResources(), resource); rounded.setCircular(true); imageView.setImageDrawable(rounded); Log.d(TAG, "setResource: " + url); } }); } catch (Exception e) { Log.e(TAG, "createRounded: ", e); } }
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 w w w . j a v a2 s .c om } 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: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);/* www. j a va 2s . com*/ view.setImageDrawable(rounded); }
From source file:com.google.android.apps.gutenberg.util.RoundedImageListener.java
@Override public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) { if (response.getBitmap() != null) { Bitmap src = response.getBitmap(); RoundedBitmapDrawable avatar = RoundedBitmapDrawableFactory.create(mImageView.getResources(), src); avatar.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f); mImageView.setImageDrawable(avatar); } else if (mDefaultImageResId != 0) { mImageView.setImageResource(mDefaultImageResId); }/* w w w . j av a 2 s . co m*/ }
From source file:nu.yona.app.ui.profile.BaseProfileFragment.java
/** * Gets image./*from w ww.ja va 2 s . com*/ * * @param bitmap the bitmap * @param withAlpha the with alpha * @param backgroundColor the background color * @param firstName the first name * @param lastName the last name * @return the image */ protected Drawable getImage(Bitmap bitmap, boolean withAlpha, int backgroundColor, String firstName, String lastName) { if (bitmap != null) {// TODO: 10/05/16 When server provides user profile image, we need to check and enable if part on base of that. RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight())); drawable.setAlpha(ALPHA); return drawable; } return null; }
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();//from w ww .j a va2 s.c om RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), source); drawable.setCornerRadius(radius); return BitmapResource.obtain(drawable.getBitmap(), bitmapPool); }
From source file:com.example.android.supportv4.graphics.RoundedBitmapDrawableActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rounded_bitmap); // Create a bitmap and set it circular. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), IMAGE_RES); mRoundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); // Get references to the inflated views. ToggleButton toggle = (ToggleButton) findViewById(R.id.toggle_round); ImageView image = (ImageView) findViewById(R.id.image); // Set up initial view state and on checked change listener. image.setImageDrawable(mRoundedBitmapDrawable); toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override/* w w w .j a v a 2s .c o m*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mRoundedBitmapDrawable.setCircular(isChecked); } }); }