Java RGB Color Convert To RGBAtoI(byte r, byte g, byte b, byte a)

Here you can find the source of RGBAtoI(byte r, byte g, byte b, byte a)

Description

RGB Ato I

License

Open Source License

Declaration

public static int RGBAtoI(byte r, byte g, byte b, byte a) 

Method Source Code

//package com.java2s;
/*//from   w w w . jav a 2  s .  c o  m
 * @(#)gl_util.java 0.3 06/11/20
 *
 * jGL 3-D graphics library for Java
 * Copyright (c) 1999-2006 Robin Bing-Yu Chen (robin@ntu.edu.tw)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version. the GNU Lesser
 * General Public License should be included with this distribution
 * in the file LICENSE.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

public class Main {
    public static int RGBAtoI(byte r, byte g, byte b, byte a) {
        return (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | b);
    }

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

    public static int RGBAtoI(float r, float g, float b, float a) {
        return RGBAtoI(FtoI(r), FtoI(g), FtoI(b), FtoI(a));
    }

    public static int FtoI(float x) {
        return (int) (x * 255.0f);
    }
}

Related

  1. rgb565ToRGB(short pixel, byte[] rgb)
  2. rgb8ToPixel(byte[] nrgb)
  3. rgb8ToRgbRBXG(byte[] rgb)
  4. rgbaToColor(int r, int g, int b, int a)
  5. rgbaToHex(String color)
  6. rgbBitfieldToString(int rgb)
  7. rgbToBgr(final byte[] pixels)
  8. RGBtoBGR(String color)
  9. rgbToBlackWhite(int pix, int threshold)