Returns the alpha component in the range 0-255. - Java 2D Graphics

Java examples for 2D Graphics:Color Alpha

Description

Returns the alpha component in the range 0-255.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int rgb = 2;
        System.out.println(getAlpha(rgb));
    }/*from   www  . j  a  v a  2  s  .  c  o  m*/

    /**
     * Returns the alpha component in the range 0-255.
     * @return the alpha component.
     * @see #getRGB
     */
    public static int getAlpha(int rgb) {
        return (rgb >> 24) & 0xff;
    }
}

Related Tutorials