Android examples for Graphics:Color RGB Value
RGB To Color
/* See http://variableinc.com/terms-use-license for the full license governing this code. */ //package com.java2s; import android.graphics.Color; import android.util.Log; public class Main { private static final int COLOR_FLOAT_TO_INT_FACTOR = 255; public static int RGBToColor(final double pRed, final double pGreen, final double pBlue) { Log.d("ColorUtils", "Before Scan= " + pRed + ", " + pGreen + " , " + pBlue);// w ww . ja v a2 s . c o m return Color.rgb(normalizeDouble(pRed), normalizeDouble(pGreen), normalizeDouble(pBlue)); } private static int normalizeDouble(double f) { double f2 = Math.max(0.0, Math.min(1.0, f)); return (int) Math.floor(f2 == 1.0 ? COLOR_FLOAT_TO_INT_FACTOR : f2 * (COLOR_FLOAT_TO_INT_FACTOR + 1)); } }