Java RGB Color Create rgbFromGrayscale(int grayscale)

Here you can find the source of rgbFromGrayscale(int grayscale)

Description

Converts a grayscale value into an RGB color space rgb integer.

License

Open Source License

Parameter

Parameter Description
grayscale The grayscale value such that (0 >= value <= 255)

Return

An rgb integer in RGB color space.

Declaration

public static int rgbFromGrayscale(int grayscale) 

Method Source Code

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

public class Main {
    /**/*from w  ww .j  av a2s  . c o m*/
     * Converts a grayscale value into an RGB color space rgb integer.
     * @param grayscale The grayscale value such that (0 >= value <= 255)
     * @return An rgb integer in RGB color space.
     */
    public static int rgbFromGrayscale(int grayscale) {
        return getRgb(grayscale, grayscale, grayscale);
    }

    /**
     * Returns an rgb integer in RGB color space from the specified red, green, and blue values.
     * @param red The red value (0 >= red <= 255).
     * @param green The green value (0 >= green <= 255).
     * @param blue The blue value (0 >= blue <= 255).
     * @return The rgb integer value in RGB color space.
     */
    public static int getRgb(int red, int green, int blue) {
        return (red << 16) | (green << 8) | blue | (255 << 24);
    }
}

Related

  1. RGBAFromHSLA(float h, float s, float l, float a)
  2. rgbClamp(float c)
  3. rgbComponents(int argb)
  4. rgbDistance(int color1, int color2)
  5. rgbFromColorInt(int c)
  6. toRGB(byte r, byte g, byte b, byte a)
  7. toRGB(final int r, final int g, final int b, final int a)
  8. toRGB(float h, float s, float l)
  9. toRGB(int alpha, int red, int green, int blue)