1
0에서 255 사이의 알파 값을 가진 두 개의 서로 다른 비트 맵을 겹쳐서 얻은 결과 비트 맵을 "계산"해야합니다. xm이 아닌 자바 코드에서이 작업을 수행해야합니다. 비트 맵이 dinamically가 아니라 리소스에서로드되기 때문입니다. .프로그래밍 방식으로 안드로이드에서 알파 블렌딩 된 비트 맵을 중첩시키는 방법은 무엇입니까?
여기 (항상 검은 색 비트 맵을 얻을 수 ...) 내 첫 번째 시도이다
private Drawable composeBitmaps(int alpha1, BitmapDrawable bm1,
int alpha2, BitmapDrawable bm2)
{
Canvas c = new Canvas();
Bitmap b1 = bm1.getBitmap();
BitmapDrawable draw1 = new BitmapDrawable(b1.copy(b1.getConfig(), true));
draw1.setAlpha(alpha1);
c.setBitmap(draw1.getBitmap());
Paint p = new Paint();
p.setAlpha(alpha2);
c.drawBitmap(bm2.getBitmap(), 0, 0, p);
return draw1;
}
...
View v = // whatever
v.setBackgroundDrawable(composeBitmaps(100, bdrawable1, 150, bdrawable2));
그리고보기는 검은 배경에 간다. 내가 도대체 뭘 잘못하고있는 겁니까?