Java RGB Color Convert To rgbToText(int red, int green, int blue)

Here you can find the source of rgbToText(int red, int green, int blue)

Description

Converts a color's RGB presentation to a textual hexadecimal representation.

License

Open Source License

Return

hexadecimal representation of RGB in lowercase.

Declaration

public static String rgbToText(int red, int green, int blue) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2015 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  w w w  .  j av a2  s  .  com*/
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * Converts a color's RGB presentation to a textual hexadecimal representation.
     * <p>
     * Example: r = 255, g = 0, b = 0 --> "#ff0000"
     * <p>
     * Note: the hexadecimal representation is lowercase
     * 
     * @return hexadecimal representation of RGB in lowercase.
     * @since 4.0-M7
     */
    public static String rgbToText(int red, int green, int blue) {
        return String.format("#%02x%02x%02x", red, green, blue);
    }
}

Related

  1. RGBtoInt(int red, int green, int blue)
  2. RGBtoInt(String rgb)
  3. RGBToInteger(int red, int green, int blue)
  4. rgbToShort(int rgb)
  5. rgbToString(float r, float g, float b)
  6. rgbToUnscaledYUV(int[][] rgb)
  7. RGBtoXYZ(float r, float g, float b)
  8. rgbToXyz(int r, int g, int b)
  9. rgbToY(int rgb)