Transform color c into a 32 bit ARGB value - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

Transform color c into a 32 bit ARGB value

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    /**//from   www .j a  v a  2 s .  co  m
     * Transform color c into a 32 bit ARGB value
     * 
     * @param c
     * @return
     */
    public static int getARGBInt(Color c) {
        return (c.getAlpha() << 24) + (c.getRed() << 16)
                + (c.getGreen() << 8) + c.getBlue();
    }

    /**
     * Get the alpha value of a 32-bit ARGB color
     * 
     * @param rgb
     * @return
     */
    public static int getAlpha(int argb) {
        return argb >> 24;
    }
}

Related Tutorials