Android yuv12 byte[] 分别获取 三通道数据

https://blog.csdn.net/gaoxiaochuan89/article/details/81435920中获取的byte[] datas。
byte[] mYUVBytes0 = null;
byte[] mYUVBytes1 = null;
byte[] mYUVBytes2 = null;
if (true == yuv12tobitmap) {//yuv12.bmp转化为yuv byte[]
    Log.e(TAG, "datas.length " + datas.length);
    int height1 = mbitmap.getHeight() * 2 / 3;
    int width1 = mbitmap.getWidth();
    Log.e(TAG, "height1 " + height1);
    Log.e(TAG, "width1 " + width1);
    mYUVBytes0 = new byte[height1 * width1];
    mYUVBytes1 = new byte[(height1 * width1 / 2)];
    mYUVBytes2 = new byte[(height1 * width1 / 2)];

    //System.arraycopy(datas, 0, mYUVBytes0, 0, height1 * width1);
    for (int i = 0; i < height1 * width1; i++) {
        mYUVBytes0[i] = (byte) datas[i];
    }
    int uv_start = height1 * width1;
    for (int i = 0; i < height1 / 2; i++)
        for (int j = 0; j < width1 / 2; j++) {
            mYUVBytes1[i * (width1) + j] = (byte) datas[uv_start + i * width1 + (j * 2)];
            mYUVBytes2[i * (width1) + j] = (byte) datas[uv_start + i * width1 + (j * 2) + 1];
        }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值