Here you can find the source of rgb2intval(int r, int g, int b)
public static int rgb2intval(int r, int g, int b)
//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; } }