[android] Image Blur with ScriptIntrinsicBlur

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ridley);

RenderScript rs = RenderScript.create(getApplicationContext());
Allocation input = Allocation.createFromBitmap(rs, bitmap);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
script.setRadius(15.f);
script.setInput(input);
script.forEach(output);
output.copyTo(bitmap);

imageView.setImageBitmap(bitmap);

 

http://developer.android.com/reference/android/renderscript/ScriptIntrinsicBlur.html

API 17버전부터 지원된다. 변환되는 속도도 아주 빠르다.

 


2018-01-30 수정

그냥 https://github.com/mmin18/RealtimeBlurView 이거 쓰는게 편하다!