Search in sources :

Example 6 with RoundedBitmapDrawable

use of androidx.core.graphics.drawable.RoundedBitmapDrawable in project android_packages_apps_Settings by omnirom.

the class Utils method convertCornerRadiusBitmap.

/**
 * Returns a bitmap with rounded corner.
 *
 * @param context application context.
 * @param source bitmap to apply round corner.
 * @param cornerRadius corner radius value.
 */
public static Bitmap convertCornerRadiusBitmap(@NonNull Context context, @NonNull Bitmap source, @NonNull float cornerRadius) {
    final Bitmap roundedBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
    final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), source);
    drawable.setAntiAlias(true);
    drawable.setCornerRadius(cornerRadius);
    final Canvas canvas = new Canvas(roundedBitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return roundedBitmap;
}
Also used : RoundedBitmapDrawable(androidx.core.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas)

Aggregations

RoundedBitmapDrawable (androidx.core.graphics.drawable.RoundedBitmapDrawable)6 Bitmap (android.graphics.Bitmap)4 Drawable (android.graphics.drawable.Drawable)2 Canvas (android.graphics.Canvas)1 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)1 BitmapImageViewTarget (com.bumptech.glide.request.target.BitmapImageViewTarget)1 SimpleTarget (com.bumptech.glide.request.target.SimpleTarget)1 TextDrawable (com.owncloud.android.ui.TextDrawable)1