List of usage examples for android.support.v4.graphics.drawable RoundedBitmapDrawableFactory create
public static RoundedBitmapDrawable create(Resources resources, InputStream inputStream)
From source file:com.ticketmaster.servos.util.picasso.RoundedBitmapTransform.java
@Override public Bitmap transform(Bitmap source) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(res, source); drawable.setCornerRadius(getCornerRadius(source)); Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig()); Canvas canvas = new Canvas(output); drawable.setAntiAlias(true);//from w ww . ja v a 2 s.c o m drawable.setBounds(0, 0, source.getWidth(), source.getHeight()); drawable.draw(canvas); if (source != output) { source.recycle(); } return output; }
From source file:com.ahmadrosid.lib.baseapp.helper.ImageViewHelper.java
public static void createRounded(Context context, File file, ImageView imageView) { Glide.with(context).load(file).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override/*from w w w . j a va 2 s . co m*/ protected void setResource(Bitmap resource) { RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(context.getResources(), resource); rounded.setCircular(true); imageView.setImageDrawable(rounded); Log.d(TAG, "setResource: " + file.getAbsoluteFile()); } }); }
From source file:org.mozilla.gecko.fxa.activities.PicassoPreferenceIconTarget.java
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { // Updating icons from Java is not supported prior to API 11. if (!AppConstants.Versions.feature11Plus) { return;/*from w ww .ja v a 2 s.co m*/ } final Drawable drawable; if (cornerRadius > 0) { final RoundedBitmapDrawable roundedBitmapDrawable; roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(resources, bitmap); roundedBitmapDrawable.setCornerRadius(cornerRadius); roundedBitmapDrawable.setAntiAlias(true); drawable = roundedBitmapDrawable; } else { drawable = new BitmapDrawable(resources, bitmap); } preference.setIcon(drawable); }
From source file:android.support.v17.leanback.supportleanbackshowcase.cards.TextCardView.java
public void updateUi(Card card) { TextView extraText = (TextView) findViewById(R.id.extra_text); TextView primaryText = (TextView) findViewById(R.id.primary_text); final ImageView imageView = (ImageView) findViewById(R.id.main_image); extraText.setText(card.getExtraText()); primaryText.setText(card.getTitle()); // Create a rounded drawable. int resourceId = card.getLocalImageResourceId(getContext()); Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), resourceId); RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap); drawable.setAntiAlias(true);//from w ww. j ava2 s. co m drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); imageView.setImageDrawable(drawable); }
From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.ImageViewSetters.java
@BindingAdapter("circleImageUrl") public static void setCircularImageUrl(final ImageView imageView, String url) { if (Strings.isNullOrEmpty(url)) { imageView.setImageBitmap(null);/* w w w.j a va2s . com*/ } else { Glide.with(imageView.getContext()).load(url).asBitmap().centerCrop() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory .create(imageView.getResources(), resource); roundedBitmapDrawable.setCircular(true); imageView.setImageDrawable(roundedBitmapDrawable); } }); } }
From source file:com.rana.contactswithemail.adapters.ContactListAdapter.java
@Override public void onBindViewHolder(final ContactListAdapter.ViewHolder holder, int position) { Contact contact = this.contactArrayList.get(position); // holder.iAvatar.setText(contact.get()); Log.e("URI", contact.getPhotoUri() + ""); Glide.with(this.context).load(contact.getPhotoUri()).asBitmap().centerCrop().placeholder(R.drawable.avatar) .into(new BitmapImageViewTarget(holder.iAvatar) { @Override/*from ww w . ja va 2 s .co m*/ protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); holder.iAvatar.setImageDrawable(circularBitmapDrawable); } }); holder.tName.setText(contact.getName()); holder.tEmail.setText(contact.getEmail()); holder.tNumber.setText(contact.getMobile()); holder.tLastCall.setText(contact.getLastContactTime()); holder.tDOB.setText(contact.getDob()); holder.tTotalTime.setText(contact.getTotalTimeFormatted()); }
From source file:com.vagabond.dealhunting.adapter.SearchAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { mHolder = (SearchItemHolder) view.getTag(); if (mHolder == null) { mHolder = new SearchItemHolder(view); }/*from w ww . java 2 s . c o m*/ Picasso.with(context).load(cursor.getString(INDEX_STORE_ICON)).into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { RoundedBitmapDrawable iconStoreDrawable = RoundedBitmapDrawableFactory .create(context.getResources(), bitmap); iconStoreDrawable.setCircular(true); mHolder.storeIcon.setImageDrawable(iconStoreDrawable); } @Override public void onBitmapFailed(Drawable errorDrawable) { } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }); mHolder.titlePromotion.setText(cursor.getString(INDEX_PROMOTION_TITLE)); view.setTag(mHolder); }
From source file:id.zelory.benih.ui.view.BenihImageView.java
public void setRoundedImageUrl(String url) { imageUrl = url;/*w w w . ja v a 2 s. c om*/ Glide.with(getContext()).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(this) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); setImageDrawable(circularBitmapDrawable); } }); }
From source file:im.vector.view.VectorCircularImageView.java
/** * Update the bitmap./*from www . jav a 2s .com*/ * The bitmap is first squared before adding corners * @param bm the new bitmap */ public void setImageBitmap(Bitmap bm) { if (null != bm) { // convert the bitmap to a square bitmap int width = bm.getWidth(); int height = bm.getHeight(); if (width == height) { // nothing to do } // larger than high else if (width > height) { try { bm = Bitmap.createBitmap(bm, (width - height) / 2, 0, height, height); } catch (Exception e) { Log.e(LOG_TAG, "## setImageBitmap - createBitmap " + e.getMessage()); } } // higher than large else { try { bm = Bitmap.createBitmap(bm, 0, (height - width) / 2, width, width); } catch (Exception e) { Log.e(LOG_TAG, "## setImageBitmap - createBitmap " + e.getMessage()); } } try { // create a rounded bitmap RoundedBitmapDrawable img = RoundedBitmapDrawableFactory.create(getResources(), bm); img.setAntiAlias(true); img.setCornerRadius(height / 2.0f); // apply it to the image this.setImageDrawable(img); } catch (Exception e) { Log.e(LOG_TAG, "## setImageBitmap - RoundedBitmapDrawableFactory.create " + e.getMessage()); super.setImageBitmap(null); } } else { super.setImageBitmap(null); } }
From source file:android.support.car.ui.CircleBitmapDrawable.java
@Override public void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); int width = bounds.right - bounds.left; int height = bounds.bottom - bounds.top; Bitmap processed = mBitmap;// w w w.j a v a 2s .c o m /* if (processed.getWidth() != width || processed.getHeight() != height) { processed = BitmapUtils.scaleBitmap(processed, width, height); } // RoundedBitmapDrawable is actually just a rounded rectangle. So it can't turn // rectangular images into circles. if (processed.getWidth() != processed.getHeight()) { int diam = Math.min(width, height); Bitmap cropped = BitmapUtils.cropBitmap(processed, diam, diam); if (processed != mBitmap) { processed.recycle(); } processed = cropped; }*/ mDrawable = RoundedBitmapDrawableFactory.create(mResources, processed); mDrawable.setBounds(bounds); mDrawable.setAntiAlias(true); mDrawable.setCornerRadius(Math.min(width, height) / 2f); if (mAlpha != -1) { mDrawable.setAlpha(mAlpha); } if (mCf != null) { mDrawable.setColorFilter(mCf); } invalidateSelf(); }