Android Color Convert getArgb(int color)

Here you can find the source of getArgb(int color)

Description

Gets an ARGB int array from a provided color

Parameter

Parameter Description
color a parameter

Declaration

public static int[] getArgb(int color) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   www .ja va  2 s  .  c om*/
     * Gets an ARGB int array from a provided color
     *
     * @param color
     * @return
     */
    public static int[] getArgb(int color) {
        final int a = (color >>> 24);
        final int r = (color >> 16) & 0xFF;
        final int g = (color >> 8) & 0xFF;
        final int b = (color) & 0xFF;

        return new int[] { ClippedColorPart(a), ClippedColorPart(r),
                ClippedColorPart(g), ClippedColorPart(b) };
    }

    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. getColorFromArgb(int[] argb)
  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)