Android Color Convert decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp, int width, int height)

Here you can find the source of decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp, int width, int height)

Description

decode YUVSP Grayscale

Declaration

static public void decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp,
            int width, int height) 

Method Source Code

//package com.java2s;

public class Main {
    static public void decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp,
            int width, int height) {
        final int frameSize = width * height;

        for (int pix = 0; pix < frameSize; pix++) {
            int pixVal = (0xff & ((int) yuv420sp[pix])) - 16;
            if (pixVal < 0)
                pixVal = 0;//ww w .  ja  va  2  s . c  o  m
            if (pixVal > 255)
                pixVal = 255;
            rgb[pix] = 0xff000000 | (pixVal << 16) | (pixVal << 8) | pixVal;
        } // pix
    }
}

Related

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