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];
        }
}

猜你喜欢

转载自blog.csdn.net/gaoxiaochuan89/article/details/81435985