Java Color Components
import
java.awt.image.DirectColorModel;
public class ShowComponents {
DirectColorModel colorModel;
int[] component1;
float[] component2;
int value;
int red, green, blue, alpha;
public ShowComponents() {
red = 40;
green = 10;
blue = 20;
alpha = 255;
colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
0x000000ff, 0xff000000);
value = (alpha << 24) + (red << 16) + (green <<
8) + blue;
component1 = colorModel.getComponents(value, null, 0);
component2 = colorModel.getNormalizedComponents(component1,0,
null,0);
System.out.println("Normalized components are: ");
for (int i = 0; i < component2.length; i++)
System.out.println("\t" + component2[i]);
}
public static void main(String[] args) {
new ShowComponents();
}
}
No comments:
Post a Comment