Tôi có một chức năng chụp một bitmap liền mạch và cuộn nó trên màn hình theo bất kỳ hướng nào bằng cách sử dụng tọa độ thế giới. Có 4 bản vẽ (khu vực phát nhỏ hơn kích thước bitmap đầy đủ .. Vì vậy, nhiều nhất, bạn sẽ thấy 4 bản sao của bitmap, chỉ các phần khác nhau được vẽ để giữ lại hiệu ứng liền mạch). Những gì tôi muốn biết là, tôi nên áp dụng sửa đổi để giới hạn rect để nó chỉ blitting các bộ phận mà nó nên lên màn hình? Hay tôi nên để Android xử lý điều đó? Và nếu tôi tự làm, tôi nên xử lý như thế nào? Thế giới phối hợp và dịch thực sự gây nhầm lẫn cho tôi, theo như toán học đi. :/Tôi có nên dựa vào Android để hủy hòa không?
Đây là mã.
public void draw(Canvas canvas){
oCoords.x=(int) fX;
oCoords.y=(int) fY;
oTopLeft = gridContainingPoint(oCoords);
oTopRight.x = gridContainingPoint(oCoords).x + iWidth;
oTopRight.y = gridContainingPoint(oCoords).y;
oBottomLeft.x = gridContainingPoint(oCoords).x;
oBottomLeft.y = gridContainingPoint(oCoords).y + iHeight;
oBottomRight.x = gridContainingPoint(oCoords).x + iWidth;
oBottomRight.y = gridContainingPoint(oCoords).y + iHeight;
canvas.save();
canvas.translate(-fX, -fY);
oCloud.setBounds(oTopLeft.x, oTopLeft.y, oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight);
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y, oTopLeft.x + (this.iImageWidth * 2), oTopLeft.y + this.iImageHeight);
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x, oTopLeft.y + this.iImageHeight, oTopLeft.x + this.iImageWidth, oTopLeft.y + (this.iImageHeight * 2));
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight, oTopLeft.x + (this.iImageWidth * 2),oTopLeft.y + (this.iImageHeight * 2));
oCloud.draw(canvas);
canvas.restore();
}