如何解决如何在Android中围绕图像制作发光效果?
我对如何在图像周围创建发光效果进行了很多研究,如下图所示
图片:
我的代码:
ImageView imageView = ((ImageView) findViewById(R.id.bmpImg))
// An added margin to the initial image
int margin = 24;
int halfMargin = margin / 2;
// the glow radius
int glowRadius = 16;
// the glow color
int glowColor = Color.rgb(0,192,255);
// The original image to use
Bitmap src = BitmapFactory.decodeResource(getResources(),R.drawable.myImg);
// extract the alpha from the source image
Bitmap alpha = src.extractAlpha();
// The output bitmap (with the icon + glow)
Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,src.getHeight() + margin,Bitmap.Config.ARGB_8888);
// The canvas to paint on the image
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setColor(glowColor);
// outer glow
paint.setMaskFilter(new BlurMaskFilter(glowRadius,Blur.OUTER));
canvas.drawBitmap(alpha,halfMargin,paint);
// original icon
canvas.drawBitmap(src,null);
imageView.setImageBitmap(bmp);
但是我没有任何效果。
任何有创意的人!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。