Created
January 8, 2015 13:35
-
-
Save lassebenni/420258cdc3c1eb42e7fd to your computer and use it in GitHub Desktop.
blurImage method
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
private Bitmap blurImage(Bitmap input) { | |
Bitmap outputBitmap = Bitmap.createBitmap(input.getWidth(), input.getHeight(), Bitmap.Config.ARGB_8888); | |
Canvas c = new Canvas(outputBitmap); | |
Paint paint = new Paint(); | |
ColorFilter filter = new LightingColorFilter(0xff727272, 0x00000000); | |
paint.setColorFilter(filter); | |
RenderScript rs = RenderScript.create(getActivity()); | |
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); | |
; | |
Allocation tmpIn = Allocation.createFromBitmap(rs, input); | |
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); | |
theIntrinsic.setRadius(25.f); | |
theIntrinsic.setInput(tmpIn); | |
theIntrinsic.forEach(tmpOut); | |
tmpOut.copyTo(outputBitmap); | |
c.drawBitmap(outputBitmap, 0, 0, paint); | |
return outputBitmap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BlurImage method copied from Spotify ListView effect guide - https://armijnvink.wordpress.com/2014/05/27/spotify-scrolling-effect-2014/