图片边缘增加光晕效果
来源:互联网 发布:电脑时钟同步软件 编辑:程序博客网 时间:2024/04/30 00:42
效果展示:
原图 效果图:
原理: 使用某种颜色替换图像非透明部分,然后与原图合成最终效果。
步骤:
1. 底色替换 , 得到如下结果:
2.与原图合成,得到最终效果
处理代码:
/** * * @param map image * @param haloWidthPx halo width, unit in pixel * @param haloColor halo color * @return source image if haloWidth is zero */ public static Bitmap addHaloForImage(Bitmap map , int haloWidthPx ,int haloColor){ if(isValidBitmap(map)){ if(haloWidthPx < 0){ haloWidthPx = 20; } if(haloWidthPx != 0){ // method one Paint p = new Paint(); p.setColor(haloColor); p.setAntiAlias(true); p.setFilterBitmap(true); MaskFilter bmf = new BlurMaskFilter(haloWidthPx, BlurMaskFilter.Blur.SOLID); p.setMaskFilter(bmf); Bitmap d = Bitmap.createBitmap(map.getWidth()+haloWidthPx * 2,map.getHeight()+haloWidthPx*2, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(d); c.drawBitmap(map.extractAlpha(),haloWidthPx,haloWidthPx,p); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); c.drawBitmap(map,haloWidthPx,haloWidthPx,p); map.recycle(); System.gc(); // end return d; } } return map; }
LIGHTEN: DARKEN:
缺点: 对非透明图片处理效果很差。处理效率很慢 40 ~ 70 ms 。
0 0
- 图片边缘增加光晕效果
- 采用Bitmap的extractAlpha产生图片边缘光晕效果
- 提取图像Alpha位图(图片边缘光晕效果)
- 采用Bitmap的extractAlpha产生图片边缘光晕效果
- 采用Bitmap的extractAlpha产生图片边缘光晕效果
- android图片特效处理之光晕效果
- android图片特效处理之光晕效果
- 去掉SrollView,GrideView,Listview,Viewpager等滑到边缘的光晕效果
- 光晕效果插件
- [UnityShader3]光晕效果
- cocos2d-x【小菜在学习】如何增加光晕效果以及CCSpriteFrameCache使用
- NGUI相关----UITexture图片边缘流光效果
- iphone图标去掉光晕效果
- 字体边框的光晕效果
- cocos2d制作动态光晕效果
- bitmap描边(光晕)效果
- Unity之太阳光晕效果
- Unity之太阳光晕效果
- codeforces 551 D. GukiZ and Binary Operations
- StarUML Windows 版本破解
- asp.net传值方法汇总
- 论ios代理和协议
- 指定区域的图片自动按比例缩小的js代码(防止页面被图片撑破)
- 图片边缘增加光晕效果
- android动画- Property Animation(下)
- python 日志打印
- 用户画像的方法与案例——从具象到抽象
- 设计模式学习笔记(未完)
- vim+taglist+ctags安装使用笔记
- openssl + tomcat 配置https
- 如何保证手机端的app访问web服务器的安全
- Android/Java回调机制带来的内存回收问题