title: Convert RGB to Hexadecimal
body: <p>If I have a <code>Color</code> 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.</p>
  
  <p>I want it to return the hexadecimal as an <code>int</code> value, not a string, or anything else. Can anyone help?</p>
  
  <p>Here is my code where I need to convert a colour to hex, using someone's answer to try to convert it:</p>
  
  <pre><code>public static void loadImageGraphics(BufferedImage image, int x, int y, int width, int height) {
      for(int yy = 0; yy &lt; height; yy++) {
          for(int xx = 0; xx &lt; width; xx++) {
              Color c = new Color(image.getRGB(xx, yy));
              pixels[x + y * width] = c.getRed() * (0xFF)^2 + c.getGreen() * 0xFF + c.getBlue();
          }
      }
  }
  </code></pre>
  
  <p>Thanks!</p>