Returns the red component in the range 0-255 in the default sRGB space. - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

Returns the red component in the range 0-255 in the default sRGB space.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int rgb = 2;
        System.out.println(getRed(rgb));
    }//from   w ww  .  ja  va 2s .  c  o  m

    /**
     * Returns the red component in the range 0-255 in the default sRGB
     * space.
     * @return the red component.
     * @see #getRGB
     */
    public static int getRed(int rgb) {
        return (rgb >> 16) & 0xFF;
    }
}

Related Tutorials