If I have a Color
object, how can I convert it's RGB values to a hexadecimal integer? I've been searching for ages, and all I've found are "Hexadecimal to RGB", or it doesn't return an Integer value, or something else that I don't want.
I want it to return the hexadecimal as an int
value, not a string, or anything else. Can anyone help?
Here is my code where I need to convert a colour to hex, using someone's answer to try to convert it:
public static void loadImageGraphics(BufferedImage image, int x, int y, int width, int height) {
for(int yy = 0; yy < height; yy++) {
for(int xx = 0; xx < width; xx++) {
Color c = new Color(image.getRGB(xx, yy));
pixels[x + y * width] = c.getRed() * (0xFF)^2 + c.getGreen() * 0xFF + c.getBlue();
}
}
}
Thanks!