Java RGB Color Convert To rgbToHex(int r, int g, int b)

Here you can find the source of rgbToHex(int r, int g, int b)

Description

rgb To Hex

License

Open Source License

Declaration

public static String rgbToHex(int r, int g, int b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String rgbToHex(int r, int g, int b) {
        String sr = Integer.toHexString(r);
        String sg = Integer.toHexString(g);
        String sb = Integer.toHexString(b);
        if (sr.length() < 2)
            sr = "0" + sr;
        if (sg.length() < 2)
            sg = "0" + sg;
        if (sb.length() < 2)
            sb = "0" + sb;
        return "#" + sr + sg + sb;
    }//from   w  ww . j  a  v  a2s. c o m
}

Related

  1. rgbToGray(int pixels)
  2. RgbToGray(int r, int g, int b)
  3. rgbToGrey(byte[] rgb)
  4. rgbToHex(final int r, final int g, final int b)
  5. RGBtoHex(int r, int g, int b)
  6. rgbToHex(int[] rgb)
  7. RGBToHex(int[] rgb)
  8. rgbToHex(String color)
  9. RGBtoHSB(int r, int g, int b, float hsbvals[])