private static Bitmap drawableToBitmap(final Drawable drawable) {
		if (drawable instanceof BitmapDrawable)
			return ((BitmapDrawable) drawable).getBitmap();
		if (drawable instanceof ColorDrawable) {
			return null;    //TODO: Support color drawable
		}
		final Bitmap bitmap = Bitmap.createBitmap(drawable.getBounds().width(), drawable.getBounds().height(), Bitmap.Config.ARGB_8888);
		final Canvas canvas = new Canvas(bitmap);
		drawable.draw(canvas);
		return bitmap;
	}
Helper for shortcut icon.

Created by Oasis on 2017/9/18.
shared/src/main/java/com/oasisfeng/island/shortcut/ShortcutIcons.java