web-dev-qa-db-ja.com

空のビットマップを作成し、androidのキャンバスに描画します

空のビットマップを作成し、そのビットマップにキャンバスを設定してから、ビットマップに任意の図形を描画したいと思います。

94
Sunil Pandey

これはおそらくあなたが考えているよりも簡単です:

int w = WIDTH_PX, h = HEIGHT_PX;

Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap
Canvas canvas = new Canvas(bmp);

// ready to draw on that bitmap through that canvas

このトピックで見つけた一連のチュートリアルは次のとおりです。 Drawing with Canvas Series

181
bigstones