Skip to content

Instantly share code, notes, and snippets.

@itoz
Created July 10, 2011 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itoz/1074517 to your computer and use it in GitHub Desktop.
Save itoz/1074517 to your computer and use it in GitHub Desktop.
java android 縦長ビットマップをアニメーション用に指定サイズに切り出して配列に
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