【发布时间】:2015-04-30 08:21:38
【问题描述】:
我试图做位图圆圈它可以工作,但高分辨率图像不能正常工作。它在图像视图中像小圆圈一样工作。
我试过这段代码,也试过很多其他代码,但都不能正常工作
public static Bitmap circleShape(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());
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
// canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
bitmap.getWidth() / 2, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
//Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
//return _bmp;
return output;
}
【问题讨论】:
-
它很模糊,我测试过
-
发布您的输出。上一条注释中的代码将图像下采样到 50*50,
targetWidth和targetHeight指定如何对原始图像进行采样。