0
나는 스트로크가있는 XML 드로어 블 파일을 가지고 있으며, 스트로크를 적용 할 여러 비트 맵을 가지고 있습니다. 나는 Drawable.draw (캔버스)를 호출 시도하지만, IllegalStateException이비트 맵에 드로어 블을 그리기
스트로크 XML 던졌습니다 :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="3dp"
android:color="#ffffffff"/>
</shape>
그리기 코드 :
Drawable strokeDrawable = getResources().getDrawable(R.drawable.stroke);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.bmp1);
Canvas canvas = new Canvas(bmp1);
strokeDrawable.draw(canvas);
내가 이걸 어떻게해야합니까?
하면 전체 로그 캣을 보여줄 수주십시오? – Eric
어리석은 나를. logcat에서 더 가까이 읽을 때 비트 맵이 변경 불가능하기 때문입니다. 방금 뇌졸중이 보이지 않지만 (아마도 비트 맵 경계에서 벗어나기는하지만)'bmp1.copy()'를 추가했고 예외를 더 이상 throw하지 않습니다. – garbagecollector
[''] (http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape) 기법을 사용해보십시오. 이것이 실패하면, 캔버스의 크기에 따라'Bitmap'의 크기를 손으로 조절해야 할 수도 있습니다. –
Eric