brighter a color : Color « 2D Graphics « Android






brighter a color

  

import android.graphics.Color;

class Main {
  public static int brighter(int c) {

    int r = Color.red(c);
    int b = Color.blue(c);
    int g = Color.green(c);

    if (r == 0 && b == 0 && g == 0) {
      return Color.DKGRAY;
    }

    if (r < 3 && r != 0) {
      r = 3;
    } else {
      r = (int) (r / .7);
      r = (r > 255) ? 255 : r;
    }

    if (b < 3 && b != 0) {
      b = 3;
    } else {
      b = (int) (b / .7);
      b = (b > 255) ? 255 : b;
    }

    if (g < 3 && g != 0) {
      g = 3;
    } else {
      g = (int) (g / .7);
      g = (g > 255) ? 255 : g;
    }

    return Color.rgb(r, g, b);
  }
}

   
    
  








Related examples in the same category

1.Using solid color to paint
2.Set color for Paint
3.Create Color from RGB value
4.Load Color from resource xml file
5.Using View to display color
6.Change check box color
7.Color Filters
8.Color Matrix Sample
9.HSV To Color
10.RGB To Color
11.lighten Color
12.Get Random Location and Colors
13.Returns the complimentary (opposite) color.
14.darker a color
15.extends View to create ColorCircle
16.Increase Red
17.Increase Contrast, Reduce Brightness
18.Decrease Saturation