0
我有圖像列表。我已經使用此功能四捨五入我的形象的角落:Android圖像模糊圓角
public Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
Bitmap output = null;
try {
if(bitmap != null) {
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 = pixels;
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);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return output;
}
它成功地輪圖像的角落,但角模糊,粗糙和像素化。角落不光滑。示例輸出:
我該如何解決這個問題?