|
Convert RGB value to Hexadecimal - To be used in HTML for example |
|
|
This tip shows how to convert a RGB values of a color into hexadecimal version.
import java.awt.*;
public class Color2Hex {
public static void main( String[] args ) {
if (args.length != 3) {
System.out.println("Color2Hex r g b");
}
else {
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
int k = Integer.parseInt(args[2]);
Color c = new Color(i,j,k);
System.out.println
( "hex: " + Integer.toHexString( c.getRGB() & 0x00ffffff ) );
}
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.