Java Code Examples for androidx.core.graphics.drawable.RoundedBitmapDrawable#setAntiAlias()
The following examples show how to use
androidx.core.graphics.drawable.RoundedBitmapDrawable#setAntiAlias() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextCardView.java From tv-samples with Apache License 2.0 | 6 votes |
public void updateUi(Card card) { TextView extraText = findViewById(R.id.extra_text); TextView primaryText = findViewById(R.id.primary_text); final 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); drawable.setCornerRadius( Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); imageView.setImageDrawable(drawable); }
Example 2
Source File: CharacterCardView.java From tv-samples with Apache License 2.0 | 5 votes |
public void updateUi(Card card) { TextView primaryText = findViewById(R.id.primary_text); final ImageView imageView = findViewById(R.id.main_image); primaryText.setText(card.getTitle()); if (card.getLocalImageResourceName() != null) { int resourceId = card.getLocalImageResourceId(getContext()); Bitmap bitmap = BitmapFactory .decodeResource(getContext().getResources(), resourceId); RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap); drawable.setAntiAlias(true); drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); imageView.setImageDrawable(drawable); } }
Example 3
Source File: UserIcon.java From FCM-for-Mojo with GNU General Public License v3.0 | 5 votes |
/** * 把 Bitmap 变圆。 * * @param context Context * @param bitmap 要处理的 Bitmap * @return 圆形的 Bitmap */ public static Bitmap clipToRound(Context context, Bitmap bitmap) { final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setAntiAlias(true); drawable.setCircular(true); drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.draw(canvas); return bitmap; }
Example 4
Source File: CircleImageView.java From ColorPickerDialog with Apache License 2.0 | 5 votes |
@Override public void onDraw(Canvas canvas) { Bitmap image = ImageUtils.drawableToBitmap(getDrawable()); if (image != null) { int size = Math.min(getWidth(), getHeight()); image = ThumbnailUtils.extractThumbnail(image, size, size); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), image); roundedBitmapDrawable.setCornerRadius(size / 2); roundedBitmapDrawable.setAntiAlias(true); canvas.drawBitmap(ImageUtils.drawableToBitmap(roundedBitmapDrawable), 0, 0, paint); } }
Example 5
Source File: GroupConversation.java From NaviBee with GNU General Public License v3.0 | 4 votes |
public Drawable getRoundIconDrawable(Resources r) { RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(r, iconBitmap); d.setAntiAlias(true); d.setCircular(true); return d; }