Created
February 4, 2015 16:59
-
-
Save eliseomartelli/08659904a55f703fea99 to your computer and use it in GitHub Desktop.
This file contains 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 Bitmap blur(Bitmap inBitmap, int radius) { | |
if (radius >= 25) { | |
radius = 25; | |
} | |
Bitmap bitmap = inBitmap.copy(inBitmap.getConfig(), true); | |
final RenderScript rs = RenderScript.create(getApplicationContext()); | |
final Allocation input = Allocation.createFromBitmap( rs, bitmap, 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); | |
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