이 코드를 사용하기 전에 잘 작동하는 스프라이트 시트 애니메이션을 화면에 그리려고합니다.다른 이미지의 일부 이미지 만들기
canvas.drawColor(Color.TRANSPARENT);
Rect src = new Rect(CurrentSprite.x * SheetSize.x, CurrentSprite.y * SheetSize.y, (CurrentSprite.x * SheetSize.x) + SheetSize.x, (CurrentSprite.y * SheetSize.y) + SheetSize.y);
Rect dst = new Rect(X, Y, X + SheetSize.x, Y + SheetSize.y);
canvas.drawBitmap(bmp, src, dst, null);
그러나 이제 이미지를 화면에 그리기 전에 회전해야합니다. 그래서 코드를 변경하여 스프라이트의 로컬 복사본을 만들었습니다. 나는 이것을 끌어낼 것입니다 그러나 여기에 문제가 생깁니다. Bitmap.createBitmap 메서드를 사용하고 있지만이 메서드는 화면을 볼 때 전체 스프라이트 시트가 화면에 그려 지기도하고 때로는 전체 이미지가 상당히 크기 때문에 OutOfMemoryException이 표시되기 때문에이 메서드는 아무 것도하지 않는 것처럼 보입니다.
canvas.drawColor(Color.TRANSPARENT);
Matrix matrix = new Matrix();
matrix.postRotate(Degrees);
Bitmap tempAnimationBmp = Bitmap.createBitmap(bmp, CurrentSprite.x * SheetSize.x, CurrentSprite.y * SheetSize.y, (CurrentSprite.x * SheetSize.x) + SheetSize.x, (CurrentSprite.y * SheetSize.y) + SheetSize.y, matrix, true);
canvas.drawBitmap(tempAnimationBmp, X, Y, null);
tempAnimationBmp.recycle();
왜 스프라이트 시트가 가득 찼습니까?
이 게시물에서 내 대답을보십시오. 난 당신이 요구 사항을 변경할 수 있다고 생각 : http://stackoverflow.com/questions/12330220/androiddraw-image-in-the-center-of-another-image/12332941#12332941 –