Home | History | Annotate | Download | only in util

Lines Matching defs:drawable

22 import android.graphics.drawable.BitmapDrawable;
23 import android.graphics.drawable.Drawable;
26 import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
27 import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
35 /** Converts the provided drawable to a bitmap using the drawable's intrinsic width and height. */
37 public static Bitmap drawableToBitmap(@Nullable Drawable drawable) {
38 return drawableToBitmap(drawable, 0, 0);
42 * Converts the provided drawable to a bitmap with the specified width and height.
44 * <p>If both width and height are 0, the drawable's intrinsic width and height are used (but in
45 * that case {@link #drawableToBitmap(Drawable)} should be used).
48 public static Bitmap drawableToBitmap(@Nullable Drawable drawable, int width, int height) {
49 if (drawable == null) {
54 if (drawable instanceof BitmapDrawable) {
55 bitmap = ((BitmapDrawable) drawable).getBitmap();
59 } else if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
65 drawable.getIntrinsicWidth(),
66 drawable.getIntrinsicHeight(),
77 drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
78 drawable.draw(canvas);
84 public static Drawable getRoundedDrawable(
85 @NonNull Context context, @Nullable Drawable photo, int width, int height) {
89 RoundedBitmapDrawable drawable =
91 drawable.setAntiAlias(true);
92 drawable.setCornerRadius(drawable.getIntrinsicHeight() / 2);
93 return drawable;