Java Color Create colorFromRGBA(int red, int green, int blue, int alpha)

Here you can find the source of colorFromRGBA(int red, int green, int blue, int alpha)

Description

Convert R, G, B, Alpha to standard 8 bit

License

Open Source License

Parameter

Parameter Description
alpha a parameter
red a parameter
green a parameter
blue a parameter

Return

standard 8 bit

Declaration

public static int colorFromRGBA(int red, int green, int blue, int alpha) 

Method Source Code

//package com.java2s;
/*/*from w  w  w . j  a  v a2  s. com*/
  This file is part of Cuber.
    
Cuber is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
Cuber 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 General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Cuber.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Convert R, G, B, Alpha to standard 8 bit
     * 
     * @param alpha
     * @param red
     * @param green
     * @param blue
     * @return standard 8 bit
     * @since 21/06/2013
     * @author wonka
     */
    public static int colorFromRGBA(int red, int green, int blue, int alpha) {
        int newPixel = 0;
        newPixel += alpha;
        newPixel = newPixel << 8;
        newPixel += red;
        newPixel = newPixel << 8;
        newPixel += green;
        newPixel = newPixel << 8;
        newPixel += blue;

        return newPixel;
    }
}

Related

  1. color(String msg)
  2. color(String s)
  3. color(String s)
  4. colorFromRGB(int r, int g, int b)
  5. colorFromRGB(int red, int green, int blue)
  6. colorFromString(String string)
  7. colorWithARGB(int alpha, int red, int green, int blue)
  8. colorWithIntAndAlpha(int color, int alpha)
  9. generateBlankImage(int w, int h, Color col)