Java RGB Color Convert To rgb2hex(int[] rgb)

Here you can find the source of rgb2hex(int[] rgb)

Description

rgbhex

License

Apache License

Declaration

static String rgb2hex(int[] rgb) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static String rgb2hex(int[] rgb) {
        return toHex(rgb[0]) + toHex(rgb[1]) + toHex(rgb[2]);
    }//  w  w w. j a  va2s  . co m

    static String rgb2hex(int r, int g, int b) {
        return rgb2hex(new int[] { r, g, b });
    }

    static String toHex(int v) {
        v = Math.min(Math.max(v, 0), 255);
        return String.valueOf("0123456789abcdef".charAt(((v - v % 16) / 16))) + //$NON-NLS-1$
                String.valueOf("0123456789abcdef".charAt(v % 16)); //$NON-NLS-1$
    }
}

Related

  1. rgb2bilevel(int[] rgb)
  2. rgb2gray(int r, int g, int b)
  3. rgb2grayscale(int[] rgb, int imageWidth, int imageHeight)
  4. rgb2grayscaleA(int[] rgb)
  5. rgb2Hex(int rgb)
  6. rgb2hsl(int colour)
  7. RGB2HSL(int red, int green, int blue, float[] hslvals)
  8. rgb2hsl(int[] rgb)
  9. rgb2hsv(int r, int g, int b)