-2
我試圖做位圖圈工作,但高分辨率圖像無法正常工作。它像圖像視圖中的小圓圈一樣工作。位圖圈不正確
我已經嘗試此代碼,我試過很多其他的代碼,卻沒有正常工作
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;
}
檢查我的答案http://stackoverflow.com/questions/18378741/how-to-make-an-imageview-in-circular-形狀/ 18378873#18378873 – Piyush
其非常模糊,我已測試 –
張貼您的輸出。前面評論中的代碼將圖像下采樣到50 * 50,'targetWidth'和'targetHeight'指定如何對原始圖像進行採樣。 – tom91136