Drawing a bitmap in a canvas after calling setBitmap doesn't work

Posted by kodbar_k on Stack Overflow See other posts from Stack Overflow or by kodbar_k
Published on 2011-05-09T13:30:05Z Indexed on 2011/06/28 8:22 UTC
Read the original article Hit count: 332

Filed under:
|
|

I'm drawing a bitmap in a canvas and i want to have the result in a new bitmap, but i still have a black screen as result. This is my code, part of the onDraw(Canvas canvas) method :

if (bitmapTemplate == null) {
canvasBis = new Canvas();
bitmapTemplate = Bitmap.createBitmap(canvas.getWidth()+30,canvas.getHeight(),Bitmap.Config.ARGB_8888);
drawZones(canvasBis,bitmapTemplate);
}

bitmapRes = Bitmap.createBitmap(canvas.getWidth()+30,canvas.getHeight(),Bitmap.Config.ARGB_8888);
canvas.setBitmap(bitmapRes);
canvas.drawBitmap(bitmapTemplate, matrix, null);

My goal is to have a new bitmap (bitmapRes) by applying a matrix on an existing bitmap (bitmapTemplate). With this code i alway have a black screen, but when i remove the line canvas.setBitmap(bitmapRes) i have a result but not in a new bitmap. any ideas please ? Maybe transparency ? Thanks in advance.

drawZones draws some zones in bitmapTemplate.

© Stack Overflow or respective owner

Related posts about android

Related posts about canvas