The halo effect of Android image effects processing

Source: Internet
Author: User

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
  1. /**
  2. * Halo effect
  3. * @param bmp
  4. * The x-coordinate of the center point of the @param x halo in BMP
  5. * @param the y-coordinate of the Y-Halo center point in BMP
  6. * @param radius of R halo
  7. * @return
  8. */
  9. Public Bitmap Halo (Bitmap bmp, int x, int y, float R)
  10. {
  11. Long start = System.currenttimemillis ();
  12. //Gaussian matrix
  13. int[] Gauss = new int[] { 1, 2, 1, 2, 4, 2, 1, 2, 1};
  14. int width = bmp.getwidth ();
  15. int height = bmp.getheight ();
  16. Bitmap Bitmap = bitmap.createbitmap (width, height, Bitmap.Config.RGB_565);
  17. int pixr = 0;
  18. int pixg = 0;
  19. int pixb = 0;
  20. int pixcolor = 0;
  21. int newr = 0;
  22. int NEWG = 0;
  23. int newb = 0;
  24. int delta = 18; //The smaller the image, the brighter the larger the darker
  25. int idx = 0;
  26. int[] pixels = new int[width * height];
  27. Bmp.getpixels (pixels, 0, width, 0, 0, width, height);
  28. for (int i = 1, length = height- 1; i < length; i++)
  29. {
  30. for (int k = 1, len = width- 1; k < Len; k++)
  31. {
  32. IDX = 0;
  33. int distance = (int) (Math.pow (K-x, 2) + Math.pow (i-y, 2));
  34. //Do not blur the point of a central area
  35. if (Distance > R * r)
  36. {
  37. For (int m =-1; m <= 1; m++)
  38. {
  39. For (int n =-1; n <= 1; n++)
  40. {
  41. Pixcolor = pixels[(i + m) * width + k + n];
  42. PIXR = Color.Red (Pixcolor);
  43. Pixg = Color.green (Pixcolor);
  44. PIXB = Color.Blue (Pixcolor);
  45. NEWR = NEWR + (int) (PIXR * gauss[idx]);
  46. NEWG = NEWG + (int) (PIXG * gauss[idx]);
  47. Newb = newb + (int) (PIXB * gauss[idx]);
  48. idx++;
  49. }
  50. }
  51. NEWR/= Delta;
  52. NEWG/= Delta;
  53. Newb/= Delta;
  54. NEWR = Math.min (255, Math.max (0, NEWR));
  55. NEWG = Math.min (255, Math.max (0, NEWG));
  56. Newb = Math.min (255, Math.max (0, newb));
  57. Pixels[i * width + K] = Color.argb (255, NEWR, NEWG, newb);
  58. NEWR = 0;
  59. NEWG = 0;
  60. Newb = 0;
  61. }
  62. }
  63. }
  64. Bitmap.setpixels (pixels, 0, width, 0, 0, width, height);
  65. Long end = System.currenttimemillis ();
  66. LOG.D ("may", "used time=" + (End-start));
  67. return bitmap;
  68. }

The halo effect of Android image effects processing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.