List of usage examples for android.graphics Color colorToHSV
public static void colorToHSV(@ColorInt int color, @Size(3) float hsv[])
From source file:Main.java
/** * Get HSV array from color//from ww w. ja v a 2 s. c o m * @param color color * @return HSV array, length = 3 */ public static float[] getHSVFromColor(int color) { float hsv[] = new float[3]; Color.colorToHSV(color, hsv); return hsv; }
From source file:Main.java
/** * Darkens the given color to use on the status bar. * @param color Brand color of the website. * @return Color that should be used for Android status bar. */// www . jav a2 s. c o m public static int computeStatusBarColor(int color) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= DARKEN_COLOR_FRACTION; return Color.HSVToColor(hsv); }
From source file:Main.java
/** * Darkens the given color to use on the status bar. * @param color Color which should be darkened. * @return Color that should be used for Android status bar. *///from w w w . jav a 2 s. c om public static int getDarkenedColorForStatusBar(int color) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= DARKEN_COLOR_FRACTION; return Color.HSVToColor(hsv); }
From source file:Main.java
public static Bitmap applySaturationFilter(Bitmap source, int level) { int width = source.getWidth(); int height = source.getHeight(); int[] pixels = new int[width * height]; float[] HSV = new float[3]; source.getPixels(pixels, 0, width, 0, 0, width, height); int index = 0; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { index = y * width + x;//from w ww . j av a 2 s . co m Color.colorToHSV(pixels[index], HSV); HSV[1] *= level; HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0)); pixels[index] |= Color.HSVToColor(HSV); } } Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmOut.setPixels(pixels, 0, width, 0, 0, width, height); return bmOut; }
From source file:Main.java
/** * Convert RGB Color to a HSV values. /*from w w w . j av a2 s .c om*/ * * <li>H (Hue) is specified as degrees in the range 0 - 360.</li> * <li>S (Saturation) is specified as a percentage in the range 1 - 100.</li> * <li>V (Value) is specified as a percentage in the range 1 - 100.</li> * * @param color the RGB color * @return the HSV values */ public static int[] colorToHSV(int color) { int[] hsv = new int[3]; float[] hsv_float = new float[3]; Color.colorToHSV(color, hsv_float); hsv[0] = (int) Math.round(hsv_float[0]); hsv[1] = (int) Math.round(hsv_float[1] * 100); hsv[2] = (int) Math.round(hsv_float[2] * 100); hsv[0] = (int) (hsv_float[0]); hsv[1] = (int) (hsv_float[1] * 100); hsv[2] = (int) (hsv_float[2] * 100); return hsv; }
From source file:Main.java
public static int brighter(int color, float factor) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= (1f + factor); // value component for (int i = 1; i < hsv.length; i++) { hsv[i] = Math.min(1.0f, hsv[i]); }/*ww w . j a v a2s . c o m*/ color = Color.HSVToColor(hsv); return color; }
From source file:Main.java
/** * * @param color//from w w w. j a v a2 s . c o m * @return */ public static int getDarkenedColor(int color) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= 0.8f; return Color.HSVToColor(hsv); }
From source file:Main.java
public static int darker(int color, float factor) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= (1f - factor); // value component color = Color.HSVToColor(hsv); return color; }
From source file:Main.java
/** Map background color preference to paper overlay color. */ public static int mapPaperColorPrefernce(int paperColorPreference) { final float hsv[] = new float[3]; Color.colorToHSV(paperColorPreference, hsv); // Map saturation to alpha. The paper bitmap below the template will provide // the white background. final int alpha = (int) (hsv[1] * 255); // Saturation and value are set to max. hsv[1] = 1.f;/* www . j a va2 s .c o m*/ hsv[2] = 1.f; return Color.HSVToColor(alpha, hsv); }
From source file:Main.java
public static int setMinValue(int color, float newValue) { float hsv[] = new float[3]; Color.colorToHSV(color, hsv); hsv[2] = Math.max(hsv[2], newValue); return Color.HSVToColor(hsv); }