Convert rgb To Gray scale color - Android android.graphics

Android examples for android.graphics:Color

Description

Convert rgb To Gray scale color

Demo Code


public class Main{
    private static int rgbToGray(int pixels) {
        // int _alpha = (pixels >> 24) & 0xFF;
        int _red = (pixels >> 16) & 0xFF;
        int _green = (pixels >> 8) & 0xFF;
        int _blue = (pixels) & 0xFF;
        return (int) (0.3 * _red + 0.59 * _green + 0.11 * _blue);
    }//from www  .  j  a v a  2  s.c  o  m

}

Related Tutorials