Java Color Encode encodeColor(int r, int g, int b)

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

Description

encode Color

License

Open Source License

Declaration

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

Method Source Code


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

import java.awt.Color;

public class Main {
    public static String encodeColor(Color color) {
        if (null == color) {
            return "0x000000";
        }//from  w  w  w  .j a  v  a2  s. co  m

        return "0x"
                + String.format("%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()).toUpperCase();
    }

    public static String encodeColor(int r, int g, int b) {
        return "0x" + String.format("%02x%02x%02x", r, g, b).toUpperCase();
    }
}

Related

  1. encode(Color color)
  2. encode(java.awt.Color c)
  3. encodeColor(Color color)
  4. encodeColor(Color color)
  5. encodeColor(Color color)
  6. encodeColorForCss(Color color)
  7. encodeRGB(Color color)
  8. encodeRGBHexString(Color color, boolean withAlpha)
  9. encodeRGBIntString(Color color, boolean withAlpha)