일반적인 res/drawable 에 있는 이미지는 라운드 처리가 둥글게 잘되고있습니다.
그런데 contacts app 과 같은 곳에서 불러오는 이미지의 경우 라운드 처리가 안먹는 문제가 있습니다.
(연락처앱의 사진)
contactInputStream = Contacts.openContactPhotoInputStream(~~~~)
Bitmap contactImage = BitmapFactory.decodeStream(contactInputStream)
위와 같이 stream을 통해서 Bitmap 에 이미지를 불러오고 해당 Bitmap을 라운드처리하는데 안되네요;;
res/drawable에 저장된 이미지도 결국 Bitmap 형식으로 돼있고,
contact에서 불러오는 이미지도 Bitmap 형식인데
왜 contact에서 불러온 이미지는 라운드 처리가 안될까요?;;
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="#FF00FF00" />
<padding android:left="7dp" android:top="7dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="4dp" />
</shape>
예전에 이부분 때문에 고민하다가... 스타일을 쓰면 되지 않을까 생각했어어요...
imageview에 라운드를 주고 bitmap은 걍 set하고 하면 될거 같았는데...
시간이 없어서 못해 봤거든요... ㅋ 그러면 될거 같았는데...
짐 이것저것 찾아봤는데... 안될거 같아요 ㅡㅡ;; ㅋ
이미지 라운드 처리 방식은 아래와 같이 하고 있습니다.
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = 10;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}