you can use Gpuimage for video preview and take picture also, just compile the jni file in gpuimage library with ndk and put the method for YuvtoRgb convert in GPUImageNativeLibrary.java class in GPUImageLibrary for android. public static void YUVtoRBGA(byte[] yuv, int width, int height, int[] rgb) { final int frameSize = width * height; int r, g, b, y1192, y, i, uvp, u, v; for (int j = 0, yp = 0; j < height; j++) { uvp = frameSize + (j >> 1) * width; u = 0; v = 0; for (i = 0; i < width; i++, yp++) { y = (0xff & ((int) yuv[yp])) - 16; if (y < 0) y = 0; if ((i & 1) == 0) { v = (0xff & yuv[uvp++]) - 128; u = (0xff & yuv[uvp++]) - 128; } y1192 = 1192 * y; r = (y1192 + 1634 * v); g = (y1192 - 833 * v - 400 * u); b = (y1192 + 2066 * u); // Java's functions are faster then 'IFs' r = Math.max(0, Math.min(r, 262143)); g = Math.max(0, Math.min(g, 262143)); b = Math.max(0, Math.min(b, 262143)); rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); // rgba, divide 2^10 ( >> 10) /* * rgb[yp] = 0xff000000 |((r << 14) & 0xff000000) | ((g << 6) & * 0xff0000) | ((b >> 2) | 0xff00); */ } } }
replace the method in GPUImageNativeLibrary.java class's public static Native YUVtoRBGA with this, and you have done.