class BottomNavigationHelper {

    protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId,
                                                Resources resources) {
        Drawable drawable = resources.getDrawable(drawableId);

        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        } else if (drawable instanceof GradientDrawable) {
            GradientDrawable gradientDrawable = (GradientDrawable) drawable;

            int width = drawable.getIntrinsicWidth() > 0 ? drawable.getIntrinsicWidth() : 27;
            int height = drawable.getIntrinsicHeight() > 0 ? drawable.getIntrinsicHeight() : 27;

            Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            gradientDrawable.setBounds(0, 0, width, height);
            gradientDrawable.setStroke(2, resources.getColor(R.color.light_grey_text));
            gradientDrawable.setColor(resources.getColor(R.color.transparent));
            gradientDrawable.setFilterBitmap(true);
            gradientDrawable.draw(canvas);
            return bitmap;
        } else {
            Bitmap bit = BitmapFactory.decodeResource(resources, drawableId);
            return bit.copy(Bitmap.Config.ARGB_8888, true);
        }
    }

}