Java Color Combine combine(int r, int g, int b, int a)

Here you can find the source of combine(int r, int g, int b, int a)

Description

Combines the R,G,B,A values back into single integer.

License

Open Source License

Parameter

Parameter Description
r the red value
g the green value
b the blue value
a the alpha value

Return

the combined integer

Declaration

public static int combine(int r, int g, int b, int a) 

Method Source Code

//package com.java2s;
/*//from   w w  w .j  a va2s  . c o m
 *   This program 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.
 *
 *   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Combines the R,G,B,A values back into single integer.
     * 
     * @param rgba   the RGBA values
     * @return      the combined integer
     */
    public static int combine(int[] rgba) {
        return combine(rgba[0], rgba[1], rgba[2], rgba[3]);
    }

    /**
     * Combines the R,G,B,A values back into single integer.
     * 
     * @param r      the red value
     * @param g      the green value
     * @param b      the blue value
     * @param a      the alpha value
     * @return      the combined integer
     */
    public static int combine(int r, int g, int b, int a) {
        return (r << 16) + (g << 8) + (b << 0) + (a << 24);
    }
}

Related

  1. combine(int r, int g, int b)
  2. combineColors(int fgColor, int bgColor, int pctFg)