Here you can find the source of decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp, int width, int height)
static public void decodeYUV420SPGrayscale(int[] rgb, byte[] yuv420sp, int width, int height)
//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 } }