我想创建一个空白位图,然后根据条件从另一个包含资源的位图中获取像素Rects来填充它。这种做法可行吗?我该如何实现?
我只想在准备好绘制时才绘制位图。
目前,我正在使用Canvas通过Rect片段来绘制位图,但在准备好之前我不需要它被绘制。
谢谢!
我只想在准备好绘制时才绘制位图。
目前,我正在使用Canvas通过Rect片段来绘制位图,但在准备好之前我不需要它被绘制。
谢谢!
Bitmap other = ...;
//create a blank bitmap
Bitmap newBitmap = Bitmap.createBitmap(other.getWidth(),
other.getHeight(), other.getConfig());
//copy some pixels from 'other'
int x=14,y=45,width=23,height=56;
int [] pixels = new int[width * height];
other.getPixels(pixels, 0, width, x, y, width, height);
newBitmap.setPixels(pixels, 0, width, x, y, width, height);