Bitmap and DrawPoint
Bitmap and DrawPoint
Android UI 中有时需要画Bitmap,那么如何画Bitmap?
利用已有资源初始化Bitmap。
//画点 private void drawPoint(Canvas canvas){ canvas.drawBitmap(pointArray[0],point.x*pointSize+xOffset,point.y*pointSize+yOffset,paint); }//根据触摸点坐标找到对应点private Point newPoint(Float x, Float y){Point p = new Point(0, 0);for (int i = 0; i < maxX; i++) {if ((i * pointSize + xOffset) <= x&& x < ((i + 1) * pointSize + xOffset)) {p.setX(i);}}for (int i = 0; i < maxY; i++) {if ((i * pointSize + yOffset) <= y&& y < ((i + 1) * pointSize + yOffset)) {p.setY(i);}}return p;}