Tue Nov 11, 2008 8:51 pm
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();
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.