![](/img/trans.png)
[英]Android - I'm trying to draw a Path on a Canvas so i can draw a signature on top of a Bitmap, but the signature is misaligned
[英]how can i “reset” the canvas (and the bitmap used to draw into) so i can draw a new bitmap into the canvas?
当我尝试加载新地图时,我的loadMap()方法生成canvas.throwIfRecycled异常。
当我开始游戏时,初始地图会加载并可以正常运行,
只有当我尝试加载新地图时,我才获得异常..
我如何“重置”画布和用于绘制的位图,以便可以重新开始使用它们?
这是我用来创建和绘制地图的方式:
picDest = Bitmap.createBitmap(width*tileSize, height*tileSize, Bitmap.Config.RGB_565);
canvas = new Canvas(picDest);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
// process tile stuffs here ...
/*
col = ....:
row = ....;
*/
pic[x][y]= Bitmap.createBitmap(sheet, col*tileSize, row*tileSize, tileSize, tileSize);
canvas.drawBitmap(pic[x][y],x*tileSize,y*tileSize,bitmPaint);
}
}
所以基本上,一旦我创建并使用了picDest和canvas,
当我想加载新地图时,我不知道如何将其全部重置。
n
如果您调用invalidate(); 它会重新绘制(因此将其重置,并按照任何新指令绘制任何内容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.