4x4 픽셀 비트 맵 (벽에있는 다른 벽돌)을 사용하여 선을 그려보고 싶습니다. 선은 어디서든 시작/정지하고 방향을 이동할 수 있습니다.캔버스로 사용자 정의 라인 만들기
나는 다음과 같은 것을 시도하고있다 :
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.brick);
int width = bm.getWidth();
int height = bm.getHeight();
float newWidth = Math.abs(line.startX - line.stopX);
float newHeight = Math.abs(line.startY - line.stopY);
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
Matrix matrix = new Matrix();
Matrix m = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(bm, (int)line.startX,(int)line.startY, width, height, matrix, false);
canvas.drawBitmap(resizedBitmap, m, paint);
나는이 오히려 .BMP 순차적으로 그리기보다는 크기 조정 것을 알고 있습니다. 또한 오류가 발생합니다. x + width must be <= bitmap.width()
여기에서 사용할 기술에 대한 제안이있는 사람이 있습니까?
겹치는 것을 방지하는 가장 조밀 한 패킹으로 순차적으로 그리거나 비트 맵을 일정한 위치의 델타로 패턴 화하려고하십니까? – hunt
겹쳐지지 않고 그림을 그리는 중 ... 'Y = MX + C'를 그려서 수직 케이스를 설명하고자하는 선의 등식을 계산할 수 있습니다. – avrono