I have a char[] rbg
containing :
rgb[0]
: red valuergb[1]
: green valuergb[2]
: blue valueI want to use the method BufferedImage::setRGB(x, y, int rgb)
How can I proceed to convert the char array to the int value ?
Note : I use Java
Edit : I'm looking for the fastest solution
Thanks
int value = ((255 & 0xFF) << 24) | //alpha
(((int)rgb[0] & 0xFF) << 16) | //red
(((int)rgb[1] & 0xFF) << 8) | //green
(((int)rgb[2] & 0xFF) << 0); //blue
import java.awt.Color;
Color color = new Color(rgb[0],rgb[1],rgb[2]);
int rgb = color.getRGB();
ref : http://download.oracle.com/javase/1.5.0/docs/api/java/awt/Color.html#getRGB%28%29
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With