Android Bitmap Blur blurFractional(int[] in, int[] out, int width, int height, float radius)

Here you can find the source of blurFractional(int[] in, int[] out, int width, int height, float radius)

Description

blur Fractional

Declaration

private static void blurFractional(int[] in, int[] out, int width,
            int height, float radius) 

Method Source Code

//package com.java2s;

public class Main {
    private static void blurFractional(int[] in, int[] out, int width,
            int height, float radius) {
        radius -= (int) radius;
        float f = 1.0f / (1 + 2 * radius);
        int inIndex = 0;

        for (int y = 0; y < height; y++) {
            int outIndex = y;

            out[outIndex] = in[0];// w  w w.  ja v a  2  s .  c  o  m
            outIndex += height;
            for (int x = 1; x < width - 1; x++) {
                int i = inIndex + x;
                int rgb1 = in[i - 1];
                int rgb2 = in[i];
                int rgb3 = in[i + 1];

                int a1 = (rgb1 >> 24) & 0xff;
                int r1 = (rgb1 >> 16) & 0xff;
                int g1 = (rgb1 >> 8) & 0xff;
                int b1 = rgb1 & 0xff;
                int a2 = (rgb2 >> 24) & 0xff;
                int r2 = (rgb2 >> 16) & 0xff;
                int g2 = (rgb2 >> 8) & 0xff;
                int b2 = rgb2 & 0xff;
                int a3 = (rgb3 >> 24) & 0xff;
                int r3 = (rgb3 >> 16) & 0xff;
                int g3 = (rgb3 >> 8) & 0xff;
                int b3 = rgb3 & 0xff;
                a1 = a2 + (int) ((a1 + a3) * radius);
                r1 = r2 + (int) ((r1 + r3) * radius);
                g1 = g2 + (int) ((g1 + g3) * radius);
                b1 = b2 + (int) ((b1 + b3) * radius);
                a1 *= f;
                r1 *= f;
                g1 *= f;
                b1 *= f;
                out[outIndex] = (a1 << 24) | (r1 << 16) | (g1 << 8) | b1;
                outIndex += height;
            }
            out[outIndex] = in[width - 1];
            inIndex += width;
        }
    }
}

Related

  1. fastblur(Bitmap sentBitmap, int radius)
  2. blur(Context context, Bitmap sentBitmap)
  3. blur(Context context, Bitmap sentBitmap, int radius)
  4. fastBlurFromView(Context context, View v, int radius)
  5. fastBlur(Context context, Bitmap renderedBmp, int radius)
  6. blurFilter(Bitmap bmp)
  7. blur(int[] in, int[] out, int width, int height, float radius)
  8. blurred(Bitmap source)
  9. fastblur(Context context, Bitmap sentBitmap, int radius)