我必须创建一个小的圆形位图。但我没有这个形象。怎么做?我无法使用
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(((float) targetWidth - 1) / 2,((float) targetHeight - 1) / 2,(Math.min(((float) 60), ((float) targetHeight)) / 2),Path.Direction.CCW);
因为我没有形象。我知道如何将图像转换为位图但不知道如何创建新的位图我尝试调整位图图像的大小而不会失去其质量并使用现有图像转换位图。
答案 0 :(得分:0)
*private Bitmap processingBitmap(int count, Bitmap bm){
int colorCode = 0xffEC5F08;
int color = 0xffe2986a;
Bitmap srcBitMap = Bitmap.createBitmap(bm.getWidth()+12, bm.getHeight()+10, Config.ARGB_8888);
Paint paint =new Paint();
paint.setColor(Color.TRANSPARENT);
paint.setStyle(Paint.Style.FILL);
RectF rect = new RectF(bm.getWidth()-25, bm.getHeight()-70,bm.getWidth()+10,bm.getHeight()-40);
Paint circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setStyle(Paint.Style.FILL);
circlePaint.setShader(new RadialGradient(srcBitMap.getWidth() / 2, srcBitMap.getHeight() / 2,
srcBitMap.getHeight() / 3, color, colorCode, TileMode.MIRROR));
Paint outCircle = new Paint();
outCircle.setStyle(Style.STROKE);
outCircle.setColor(Color.WHITE);
outCircle.setTextAlign(Paint.Align.CENTER);
outCircle.setAntiAlias(true);
outCircle.setStrokeWidth(3.5f);
Paint textPaint = new Paint();
textPaint.setStyle(Style.FILL);
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(15);
textPaint.setAntiAlias(true);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setFakeBoldText(true);
Paint borderPaint = new Paint();
borderPaint.setStrokeWidth(3f);
borderPaint.setAntiAlias(true);
borderPaint.setColor(Color.TRANSPARENT);
borderPaint.setStrokeWidth(3f);
Rect drawRect = new Rect(0, srcBitMap.getWidth(), srcBitMap.getWidth(), 0);
Canvas canvas = new Canvas(srcBitMap);
canvas.drawRect(drawRect, paint);
canvas.drawBitmap(bm, 0, 8, null);
canvas.drawOval(rect, outCircle);
canvas.drawOval(rect, circlePaint);
canvas.drawText(Integer.toString(count), bm.getWidth()-8.2f, bm.getHeight()/3.25f, textPaint);
return srcBitMap;
}*