from Normalized RGB - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

from Normalized RGB

Demo Code


//package com.java2s;

public class Main {
    public static int fromNormalizedRGB(float r, float g, float b) {
        return fromNormalizedRGBA(r, g, b, 1f);
    }/*from w w  w  . j  a  v a 2  s. c  om*/

    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);
    }

    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