Illumination effects of special image effects in Android system

Source: Internet
Author: User

I have made an image browser and used some image processing algorithms. This is part of it. APK installation package address: http://static.apk.hiapk.com/html/2012/08/797656.html. Welcome to download and feedback;

Illumination effects of special image effects in Android system

Public static bitmap sunshine (softreference <bitmap> BMP) {final int width = BMP. get (). getwidth (); Final int Height = BMP. get (). getheight (); log. D ("Sunshine", "Sunshine: width" + width + "height:" + height); 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 centerx = width/ 2; int centery = height/2; int radius = math. Min (centerx, centery); Final float strength = 150f; // illumination intensity 100 ~ 150 int [] pixels = new int [width * Height]; BMP. get (). getpixels (pixels, 0, width, 0, 0, width, height); int Pos = 0; // BMP. recycle (); // BMP = NULL; For (INT I = 1, length = height-1; I <length; I ++) {for (int K = 1, len = width-1; k <Len; k ++) {pos = I * width + k; pixcolor = pixels [POS]; pixr = color. red (pixcolor); pixg = color. green (pixcolor); pixb = color. blue (pixcolor); newr = pixr; newg = pixg; newb = pixb; // calculate the distance from the current point to the light center, distance between two points in a plane coordinate system V int distance = (INT) (math. pow (centery-I), 2) + math. pow (centerx-K, 2); If (distance <radius * radius) {// calculate the added illumination value by distance int result = (INT) (strength * (1.0-math. SQRT (distance)/radius); newr = pixr + result; newg = pixg + result; newb = pixb + result;} 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 [POS] = color. argb (255, newr, newg, newb) ;}} bitmap. setpixels (pixels, 0, width, 0, 0, width, height); Return bitmap ;}

 

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.