转换yuv,把数据用txt 保存下来,但是yuv viewer一直打不开,非常苦恼,调试很多天确认代码没问题,用matlab显示出来,uv分量应该是原图宽高的1/2采样,却不明白为何出现了1/4采样,后来发现图像是480*720的,按照内存地址排放顺序,本来都是U分量结果被拆成了2张图,所以,这个结果应该是正确的
至于为什么软件打不开,应该是yuv图片本身除了数据还具有其他的格式来说明,就像BMP的文件头一样,但是网上没有资料,所以这部分等我有时间再丰富吧!
Uint8 * rgb2gray = malloc(sizeof(char) * (width*height*1.5));
Uint8 * rgb2grayY = malloc(sizeof(char) * (lenghth));
Uint8 * rgb2grayU= malloc(sizeof(char) * (lenghth / 4));
Uint8 * rgb2grayV= malloc(sizeof(char) * (lenghth / 4));
ARGBToI420(bitmapPixels, bitmapInfo.stride,
rgb2grayY, bitmapInfo.width,
rgb2grayU, bitmapInfo.width / 2,
rgb2grayV, bitmapInfo.width / 2,
bitmapInfo.width, bitmapInfo.height);
memcpy(rgb2gray, rgb2grayY, lenghth);
memcpy(rgb2gray + lenghth, rgb2grayU, lenghth/4);
memcpy(rgb2gray + lenghth*5/4, rgb2grayV, lenghth/4);
转270度,分别测试的代码,所以和前图不一样了
Uint8 dst270 = malloc(sizeof(char) * (lenghth1.5));
Uint8 *dst270_y = malloc(sizeof(char) * (lenghth));
Uint8 *dst270_u = malloc(sizeof(char) * (lenghth / 4));
Uint8 *dst270_v = malloc(sizeof(char) * (lenghth / 4));
int dst270_width = bitmapInfo.height;
int dst270_height= bitmapInfo.width;
I420Rotate( rgb2grayY, dst270_height,
rgb2grayU, (dst270_height + 1) / 2,
rgb2grayV, (dst270_height + 1) / 2,
dst270_y, dst270_width,
dst270_u, (dst270_width + 1) / 2,
dst270_v, (dst270_width + 1) / 2,
dst270_height, dst270_width,
270);
memcpy(dst270, dst270_y, lenghth);
memcpy(dst270+ lenghth, dst270_u, lenghth/4);
memcpy(dst270+ lenghth*5/4, dst270_v, lenghth/4);