Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
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
You can’t perform that action at this time.