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;
}
Aggregations