我正在尝试创建一个在位图上放置拖放着色的方法。
我现在的代码不适合我,有人能告诉我我做错了什么吗?
public static Bitmap addShadow(Bitmap bitmap) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int radius = Math.min(h / 2, w / 2);
Bitmap output = Bitmap.createBitmap(w + 12, h + 12, Bitmap.Config.ARGB_8888);
Paint p = new Paint();
Canvas c = new Canvas(output);
c.drawARGB(0, 0, 0, 0);
p.setStyle(Paint.Style.FILL);
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
p.setAntiAlias(true);
p.setColor(Color.WHITE);
p.setTextSize(45.0f);
p.setStrokeWidth(2.0f);
p.setStyle(Paint.Style.STROKE);
p.setShadowLayer(5.0f, 10.0f, 10.0f, Color.BLACK);
c.drawBitmap(bitmap, 4, 4, p);
c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, p);
return output;
}