Java RGB Color Convert To rgb8ToPixel(byte[] nrgb)

Here you can find the source of rgb8ToPixel(byte[] nrgb)

Description

rgb To Pixel

License

Open Source License

Declaration

public static int rgb8ToPixel(byte[] nrgb) 

Method Source Code

//package com.java2s;
/*/*from ww  w.  ja v a 2  s  .  com*/
  ColorMapUtils.java
    
  (c) 2011-2013 Edward Swartz
    
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the Eclipse Public License v1.0
  which accompanies this distribution, and is available at
  http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    public static int rgb8ToPixel(byte[] nrgb) {
        return ((nrgb[0] & 0xff) << 16) | ((nrgb[1] & 0xff) << 8) | (nrgb[2] & 0xff);
    }

    public static int rgb8ToPixel(int[] prgb) {
        return (Math.max(0, Math.min(prgb[0], 255)) << 16) | (Math.max(0, Math.min(prgb[1], 255)) << 8)
                | Math.max(0, Math.min(prgb[2], 255));
    }
}

Related

  1. rgb2xyz(double[] rgb, double[] xyz)
  2. RGB2YCbCr(int r, int g, int b, boolean useBT601)
  3. RGB2YCbCr(int[] rgb, float[][] Y, float[][] Cb, float[][] Cr, int imageWidth, int imageHeight)
  4. rgb2yuv(float r, float g, float b, float[] yuv)
  5. rgb565ToRGB(short pixel, byte[] rgb)
  6. rgb8ToRgbRBXG(byte[] rgb)
  7. rgbaToColor(int r, int g, int b, int a)
  8. rgbaToHex(String color)
  9. RGBAtoI(byte r, byte g, byte b, byte a)