List of usage examples for android.renderscript ScriptIntrinsicBlur setInput
public void setInput(Allocation ain)
From source file:com.creativeongreen.imageeffects.MainActivity.java
public static Bitmap blurRenderScript(Bitmap bmImage, int radius, View v) { final float BITMAP_SCALE = 0.4f; final float BLUR_RADIUS = 7.5f; int width = Math.round(bmImage.getWidth() * BITMAP_SCALE); int height = Math.round(bmImage.getHeight() * BITMAP_SCALE); Bitmap inputBitmap = Bitmap.createScaledBitmap(bmImage, width, height, false); Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap); RenderScript rs = RenderScript.create(v.getContext()); Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); //Allocation tmpIn = Allocation.createFromBitmap(rs, bmImage, // Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); //Allocation tmpOut = Allocation.createTyped(rs, tmpIn.getType()); ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); theIntrinsic.setRadius(radius);/* w w w . j a v a 2 s . c o m*/ theIntrinsic.setInput(tmpIn); theIntrinsic.forEach(tmpOut); tmpOut.copyTo(outputBitmap); return outputBitmap; }
From source file:com.codename1.impl.android.AndroidImplementation.java
public Image gaussianBlurImage(Image image, float radius) { try {/* ww w. j av a2 s .c om*/ Bitmap outputBitmap = Bitmap.createBitmap((Bitmap) image.getImage()); RenderScript rs = RenderScript.create(getContext()); ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); Allocation tmpIn = Allocation.createFromBitmap(rs, (Bitmap) image.getImage()); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); theIntrinsic.setRadius(radius); theIntrinsic.setInput(tmpIn); theIntrinsic.forEach(tmpOut); tmpOut.copyTo(outputBitmap); return new NativeImage(outputBitmap); } catch (Throwable t) { brokenGaussian = true; return image; } }