Created
July 10, 2011 12:52
-
-
Save itoz/1074518 to your computer and use it in GitHub Desktop.
java android bitmap drawableの変換いろいろ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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