lassebenni
1/8/2015 - 1:35 PM

blurImage method

blurImage method

 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;
    }