Android examples for android.graphics:Bitmap Convert
Converts a bitmap in a rounded drawable
import android.content.Context; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Paint; import android.os.Build; import android.support.v4.graphics.drawable.RoundedBitmapDrawable; import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; import android.widget.ImageView; public class Main{ /**/* w w w. ja v a 2s . c o m*/ * Converts a bitmap in a rounded drawable. * * @param context * @param bitmap * @return */ public static RoundedBitmapDrawable getRoundedImageDrawable( Context context, Bitmap bitmap) { RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory .create(context.getResources(), bitmap); roundedBitmapDrawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); return roundedBitmapDrawable; } }