This will address the image halo effect of image effects. The same as the front face is the pixel processing, the idea of this implementation can be found in the Android image processing series nine--image effects processing of the second-blur effect and Android image processing series 13--image effects processing of the six-light effect. The effect is that the pixels within the circle do not change, and the dots outside the circle are blurred. So the use of the blur effect and lighting effect is within the circle of the algorithm, can be said to be mentioned above the two effect of the combination.
See below:
Original:
:
Halo effect is not very obvious, fuzzy strength is not enough, but also can obviously see a circle in the picture, the inner circle area than the outside of the circle to see clearly a point (mm of the left and right face can see the effect). The processing effect is not very good, here can only initiate. Paste the following code:
[Java]View PlainCopy
- /**
- * Halo effect
- * @param bmp
- * The x-coordinate of the center point of the @param x halo in BMP
- * @param the y-coordinate of the Y-Halo center point in BMP
- * @param radius of R halo
- * @return
- */
- Public Bitmap Halo (Bitmap bmp, int x, int y, float R)
- {
- Long start = System.currenttimemillis ();
- //Gaussian matrix
- int[] Gauss = new int[] { 1, 2, 1, 2, 4, 2, 1, 2, 1};
- int width = bmp.getwidth ();
- int height = bmp.getheight ();
- Bitmap Bitmap = bitmap.createbitmap (width, height, Bitmap.Config.RGB_565);
- int pixr = 0;
- int pixg = 0;
- int pixb = 0;
- int pixcolor = 0;
- int newr = 0;
- int NEWG = 0;
- int newb = 0;
- int delta = 18; //The smaller the image, the brighter the larger the darker
- int idx = 0;
- int[] pixels = new int[width * height];
- Bmp.getpixels (pixels, 0, width, 0, 0, width, height);
- for (int i = 1, length = height- 1; i < length; i++)
- {
- for (int k = 1, len = width- 1; k < Len; k++)
- {
- IDX = 0;
- int distance = (int) (Math.pow (K-x, 2) + Math.pow (i-y, 2));
- //Do not blur the point of a central area
- if (Distance > R * r)
- {
- For (int m =-1; m <= 1; m++)
- {
- For (int n =-1; n <= 1; n++)
- {
- Pixcolor = pixels[(i + m) * width + k + n];
- PIXR = Color.Red (Pixcolor);
- Pixg = Color.green (Pixcolor);
- PIXB = Color.Blue (Pixcolor);
- NEWR = NEWR + (int) (PIXR * gauss[idx]);
- NEWG = NEWG + (int) (PIXG * gauss[idx]);
- Newb = newb + (int) (PIXB * gauss[idx]);
- idx++;
- }
- }
- NEWR/= Delta;
- NEWG/= Delta;
- Newb/= Delta;
- NEWR = Math.min (255, Math.max (0, NEWR));
- NEWG = Math.min (255, Math.max (0, NEWG));
- Newb = Math.min (255, Math.max (0, newb));
- Pixels[i * width + K] = Color.argb (255, NEWR, NEWG, newb);
- NEWR = 0;
- NEWG = 0;
- Newb = 0;
- }
- }
- }
- Bitmap.setpixels (pixels, 0, width, 0, 0, width, height);
- Long end = System.currenttimemillis ();
- LOG.D ("may", "used time=" + (End-start));
- return bitmap;
- }
The halo effect of Android image effects processing