Android Color Convert getColorFromArgb(int[] argb)

Here you can find the source of getColorFromArgb(int[] argb)

Description

Gets an int color from an int[4] containing argb values.

Parameter

Parameter Description
argb a parameter

Return

an int containing the result color

Declaration

public static int getColorFromArgb(int[] argb) 

Method Source Code

//package com.java2s;

public class Main {
    /**// www  .  jav  a  2s .  com
     * Gets an int color from an int[4] containing argb values.
     * @param argb
     * @return an int containing the result color
     */
    public static int getColorFromArgb(int[] argb) {

        if (argb.length != 4) {
            throw new IllegalArgumentException(
                    "ARGB int array must have a length of 4.");
        }

        return (ClippedColorPart(argb[0]) << 24)
                + (ClippedColorPart(argb[1]) << 16)
                + (ClippedColorPart(argb[2]) << 8)
                + (ClippedColorPart(argb[3]));
    }

    public static int ClippedColorPart(int color) {
        if (color < 0) {
            return 0;
        } else if (color > 0xFF) {
            return 0xFF;
        }
        return color;
    }
}

Related

  1. RGBToColor(final float pRed, final float pGreen, final float pBlue)
  2. getArgb(int color)
  3. decodeYUV420SP(int[] rgb, byte[] yuv420sp, int width, int height)
  4. decodeYUV420SP(int[] rgb, byte[] yuv420sp, int width, int height)
  5. decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp, int width, int height)
  6. rgbToGray(int pixels)