-1
public static Bitmap getCircularBitmapWithWhiteBorder(Bitmap bitmap, int borderWidth) { if (bitmap == null || bitmap.isRecycled()) { return null; } final int width = bitmap.getWidth() + borderWidth; final int height = bitmap.getHeight() + borderWidth; Bitmap canvasBitmap = Bitmap.createBitmap(width*2, height, Bitmap.Config.ARGB_8888); BitmapShader shader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setShader(shader); Canvas canvas = new Canvas(canvasBitmap); float radius = width > height ? ((float) height)/2f : ((float) width)/2f; canvas.drawCircle(width/2, height/2, radius, paint); paint.setShader(null); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.WHITE); paint.setStrokeWidth(borderWidth); canvas.drawCircle(width/2, height/2, radius - borderWidth/2, paint); return canvasBitmap; }
我有圓形的形象,我想接下來的重視圓形圖像不大不小的rectangle..similar的他 這是一個圓圈,旁邊有一個矩形連接。我怎樣才能做到這一點?畫布繪製矩形的Android
正確調整參數,它定位在rectabgle是3面,只有一人失蹤是一個連接到圓形圓形圖片 – user3278732
點擊圖片鏈接查看圖片更好的原因背景稍顯透明http://i.stack.imgur.com/1UGEb.png – user3278732