from Normalized RGBA - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

from Normalized RGBA

Demo Code


//package com.java2s;

public class Main {
    public static int fromNormalizedRGBA(float r, float g, float b, float a) {
        return fromRGBA((int) r * 255, (int) g * 255, (int) b * 255,
                (int) a * 255);
    }//from   w  w w. jav  a 2 s .c  o  m

    public static int fromRGBA(int r, int g, int b, int a) {
        return (a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | b & 255;
    }
}

Related Tutorials