Merge branch 'blur_upd' into master-rx-java-2
This commit is contained in:
commit
de52c32e98
|
|
@ -31,13 +31,16 @@ public final class BlurUtils {
|
|||
@Nullable
|
||||
public static Bitmap blurRenderscript(@NonNull final Context context, @NonNull final Bitmap bitmap, final int radius) throws RSRuntimeException {
|
||||
RenderScript rs = null;
|
||||
Allocation input = null;
|
||||
Allocation output = null;
|
||||
ScriptIntrinsicBlur blur = null;
|
||||
try {
|
||||
rs = RenderScript.create(context);
|
||||
final Allocation input =
|
||||
Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
|
||||
Allocation.USAGE_SCRIPT);
|
||||
final Allocation output = Allocation.createTyped(rs, input.getType());
|
||||
final ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
rs.setMessageHandler(new RenderScript.RSMessageHandler());
|
||||
input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
|
||||
Allocation.USAGE_SCRIPT);
|
||||
output = Allocation.createTyped(rs, input.getType());
|
||||
blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
|
||||
blur.setInput(input);
|
||||
blur.setRadius(radius);
|
||||
|
|
@ -47,6 +50,15 @@ public final class BlurUtils {
|
|||
if (rs != null) {
|
||||
rs.destroy();
|
||||
}
|
||||
if (input != null) {
|
||||
input.destroy();
|
||||
}
|
||||
if (output != null) {
|
||||
output.destroy();
|
||||
}
|
||||
if (blur != null) {
|
||||
blur.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
|
|
|
|||
Loading…
Reference in New Issue