Java RGB Color Convert To rgb2intval(int r, int g, int b)

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

Description

rgbintval

License

Open Source License

Declaration

public static int rgb2intval(int r, int g, int b) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ******************************************************************************/

public class Main {
    public static int rgb2intval(int r, int g, int b) {
        int temp = 0xff000000 | (r << 16) | (g << 8) | b;
        return temp;
    }//www . j  a v  a2 s. c  o m

    public static int rgb2intval(float r, float g, float b) {
        int r2 = (int) r;
        if (r2 > 255)
            r2 = 255;
        if (r2 < 0)
            r2 = 0;
        int g2 = (int) g;
        if (g2 > 255)
            g2 = 255;
        if (g2 < 0)
            g2 = 0;
        int b2 = (int) b;
        if (r2 > 255)
            b2 = 255;
        if (b2 < 0)
            b2 = 0;
        int temp = 0xff000000 | (r2 << 16) | (g2 << 8) | b2;
        return temp;
    }

    public static int rgb2intval(byte r, byte g, byte b) {
        int temp = 0xff000000 | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
        return temp;
    }
}

Related

  1. rgb2hsl(int colour)
  2. RGB2HSL(int red, int green, int blue, float[] hslvals)
  3. rgb2hsl(int[] rgb)
  4. rgb2hsv(int r, int g, int b)
  5. rgb2int(final int[] color)
  6. rgb2lab(int R, int G, int B)
  7. rgb2luv(double[] rgb, double[] luv)
  8. rgb2xyz(double[] RGB)
  9. rgb2xyz(double[] rgb, double[] xyz)