开发者

Populate a blank bitmap with pixels from another bitmap in Android?

I want to create a blank bitmap, which I will conditional开发者_如何转开发ly fill with Rects of pixels obtained from another bitmap that holds a resource. Is it possible to do that? How would I go about doing something like that?

I only want to draw the bitmap once it is ready to be drawn.

Right now I'm using Canvas to draw the bitmap using Rect segments, but I don't need it to be drawn until it is ready.

Thanks!


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜