Java RGB Color Create rgbComponents(int argb)

Here you can find the source of rgbComponents(int argb)

Description

Breaks a Processing color into R, G and B values in an array.

License

Open Source License

Parameter

Parameter Description
argb a Processing color as a 32-bit integer

Return

an array of integers in the intRange 0..255 for 3 primary color components: {R, G, B}

Declaration

public static int[] rgbComponents(int argb) 

Method Source Code

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

public class Main {
    /**//from  www  .jav a  2 s . co  m
     * Breaks a Processing color into R, G and B values in an array.
     * @param argb   a Processing color as a 32-bit integer 
     * @return       an array of integers in the intRange 0..255 for 3 primary color components: {R, G, B}
     */
    public static int[] rgbComponents(int argb) {
        int[] comp = new int[3];
        comp[0] = (argb >> 16) & 0xFF; // Faster way of getting red(argb)
        comp[1] = (argb >> 8) & 0xFF; // Faster way of getting green(argb)
        comp[2] = argb & 0xFF; // Faster way of getting blue(argb)
        return comp;
    }
}

Related

  1. rgbaColour(int red, int green, int blue, int alpha)
  2. RGBAequals(float[] rgba1, float[] rgba2, float eps)
  3. RGBAFromHEX(String stringValue)
  4. RGBAFromHSLA(float h, float s, float l, float a)
  5. rgbClamp(float c)
  6. rgbDistance(int color1, int color2)
  7. rgbFromColorInt(int c)
  8. rgbFromGrayscale(int grayscale)
  9. toRGB(byte r, byte g, byte b, byte a)