一行代码实现高斯模糊
前言:有一个音乐播放器的项目,背景需要根据歌曲的封面进行模糊展示,搜罗了很久,找到一个不错的解决方案,不需要我们进行NDK的开发,android帮我们在framework实现好了借鉴 /** * 模糊图片 * @param bitmap 原图片 * @param radius 模糊度 0~25 * @param context * @return 模糊后的图片 */ public static Bitmap blurBitmap(Bitmap bitmap, float radius, Context context) { //Create renderscript RenderScript rs = RenderScript.create(context); //Create allocation from Bitmap Allocation allocation = Allocation.createFromBitmap(rs, bitmap); Type t = allocation.getType(); //Create allocation with the same typ...
