Draw multiple times from a single bitmap

主宰稳场 提交于 2020-01-03 00:40:29

问题


I am trying to draw a board which consists of 35 small blocks and each small block is similar but when I use a bitmap to draw multiple times i.e 35 times then it clears the previous drawn image. At the end there is only one image left. So can anybody help me finding a solution for this.

Here is the code which I tried

protected void onDraw(Canvas canvas) { Bitmap  empty=BitmapFactory.decodeResource(getResources(), R.drawable.empty);
   for(int i=0;i<5;i++){
    for(int j=0;j<7;j++){
        canvas.drawBitmap(empty, curX, curY, null);
        curX +=blockWidth;
    }
    curY=curY+blockHeight;
     curX=0;
   }
  }

(curX->it keep track of the x coordinate and curY->keep track of y coordinate initial value of both curX and curY are 0, blockWeidth and blockHeight are constants with value 70px and 65px respectively)

来源:https://stackoverflow.com/questions/9789316/draw-multiple-times-from-a-single-bitmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!