Created
February 24, 2014 11:23
-
-
Save blaswan/9186683 to your computer and use it in GitHub Desktop.
getBlurredBitmap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Bitmap blur(Context context, Bitmap sentBitmap, int radius) { | |
if (VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { | |
Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true); | |
final RenderScript rs = RenderScript.create(context); | |
final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); | |
final Allocation output = Allocation.createTyped(rs, input.getType()); | |
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); | |
script.setRadius(radius); //0.0f ~ 25.0f | |
script.setInput(input); | |
script.forEach(output); | |
output.copyTo(bitmap); | |
return bitmap; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment