Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Color; public class Main { public static int transformIfTooWhite(int color) { int alpha = Color.alpha(color); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); float whiteRatio = (red + green + blue) / 3f / 255f * (alpha / 255f); float transformRatio = 0.7f; if (whiteRatio > transformRatio) { red *= transformRatio; green *= transformRatio; blue *= transformRatio; color = Color.argb(alpha, red, green, blue); } return color; } }