gpuimage android 录像,GPUimage port for android

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值