Java examples for 2D Graphics:Color RGB
to Normalized RGB
//package com.java2s; public class Main { public static float[] toNormalizedRGB(int color) { return toNormalizedRGBA(color | 255 << 24); }// w w w.java 2 s . c o m public static float[] toNormalizedRGBA(int color) { int[] rgba = toRGBA(color); return new float[] { rgba[0] / 255f, rgba[1] / 255f, rgba[2] / 255f, rgba[3] / 255f }; } public static int[] toRGBA(int color) { int alpha = color >> 24 & 255; int red = color >> 16 & 255; int green = color >> 8 & 255; int blue = color & 255; return new int[] { red, green, blue, alpha }; } }