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
Bitmap.Config conf = Bitmap.Config.ARGB_4444; // 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
2 回答
这可能比你想的更简单:
在这里找到's a series of tutorials I' ve:Drawing with Canvas Series
不要使用Bitmap.Config.ARGB_8888
而是使用int w = WIDTH_PX,h = HEIGHT_PX;
处理更多位图或大位图时,ARGB_8888会让您陷入OutOfMemory问题 . 或者更好的是,尝试避免使用ARGB选项本身 .