我一直在网上搜索如何将画布上的内容转换为位图.我尝试了多种方法来实现这一点,例如将绘图缓存保存到位图,但最终结果是背景位图闪烁了一会儿,然后变成了黑屏.测试图像显示在背景上,但不会被下次调用的背景覆盖OnDraw.
MainThreading{
...
if(notuptodate == true){
//call readyBackground to create the background bitmap
this.mainPanel.readyBackground(canvas);
//post the canvas
surfaceHolder.unlockCanvasAndPost(canvas);
//clean the Canvas
canvas = null;
//ready new Canvas
canvas = this.surfaceHolder.lockCanvas();//lock the canvas to enable editing
}//if not true
if (MainThreading.notuptodate == false){
mainPanel.onDraw(canvas);
}//if false
...
}//mainthreading
//this method is run first to create the Bitmap that on draw will use
public void readyBackGround(Canvas canvas){
if (MainThreading.notuptodate){
//method used to draw multiple Bitmaps onto the canvas
renderBackground(canvas);
//private …Run Code Online (Sandbox Code Playgroud)