Skip to content

Instantly share code, notes, and snippets.

@itoz itoz/gist:1074518
Created Jul 10, 2011

Embed
What would you like to do?
java android bitmap drawableの変換いろいろ
//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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.