convertImage.java
//Resource → Bitmap
BitmapFactory.decodeResource(getResources(), R.drawable.icon);
//Resource → Drawable
getResources().getDrawable(R.drawable.icon);
/**
* Bitmap→Drawableに変換
* @param bitmap
* @return BitmapDrawable
*/
public static BitmapDrawable convert(Bitmap bitmap)
{
return new BitmapDrawable(bitmap);
}
/**
* Drawable→Bitmapに変換
* @param drawable
* @return Bitmap
*/
public static Bitmap convert(Drawable drawable)
{
return ((BitmapDrawable) drawable).getBitmap();
}