Created
July 10, 2011 12:51
-
-
Save itoz/1074517 to your computer and use it in GitHub Desktop.
java android 縦長ビットマップをアニメーション用に指定サイズに切り出して配列に
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
public ArrayList<Bitmap> split(Drawable drawable, int width, int height) | |
{ | |
// 縦長Drawableをビットマップに | |
Bitmap bitmapOrg = ((BitmapDrawable) drawable).getBitmap(); | |
//分割bitmapにして配列に保存 | |
int masterHeight = bitmapOrg.getHeight(); | |
int max = masterHeight / height; | |
_matrix = new Matrix(); | |
for (int i = 0; i < max; i++) { | |
Bitmap splitBitmap = Bitmap.createBitmap(bitmapOrg, 0, (height * i), width, height, _matrix, true); | |
_bmArray.add(splitBitmap); | |
} | |
//縦長ビットマップ解放 | |
if(bitmapOrg.isRecycled()){ | |
bitmapOrg.recycle(); | |
} | |
return _bmArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment