I420转RGB24
来源:互联网 发布:龙骑战歌gm数据 编辑:程序博客网 时间:2024/06/12 00:43
现在网上这些人写的要么不对 要么颜色溢出 要么偏黄 偏蓝 偏红 。真的是够了。
试一试下面就知道对不对了。
I420也叫IYUV,也叫YUV420 。 采集卡采集视屏数据通常为I420 经过转换成rgb24后 可以对图像进行各种处理。
下面来说说i420转rgb24:
unsigned char* I420ToRGBA(const unsigned char * src, int width, int height)
{
//我的图片是1920*1080的 你们按照自己*3就可以
unsigned char* rgbA = new unsigned char[1920*1080*3];
int temp = 0;
for(int i=0; i<height; i++){
int startY = i*width;
int step = (i/2)*(width/2);
int startV = positionOfV + step;
int startU = positionOfU + step;
for(int j = 0; j < width; j++){
int Y = startY + j;
int V = startV + j/2;
int U = startU + j/2;
int index = Y*3;
temp = ((src[Y]&0xff) + 1.4075 * ((src[V]&0xff)-128));
rgbA[index+B] = temp<0 ? 0 : (temp > 255 ? 255 : temp);
temp = ((src[Y]&0xff) - 0.3455* ((src[U]&0xff)-128) - 0.7169*((src[V]&0xff)-128));
rgbA[index+G] = temp<0 ? 0 : (temp > 255 ? 255 : temp);
temp = ((src[Y]&0xff) + 1.779* ((src[U]&0xff)-128));
rgbA[index+R] =temp<0 ? 0 : (temp > 255 ? 255 : temp);
}
}
return rgbA;
}
使用方法:
int main(void)
{
// 参数1. 待转换的I420数据 ,参数二 图片宽度 ,参数三 图片的高度 ,返回值 :指向转换后的数据 也就是指向rgb24数据
unsigned char* rgb24 = I420ToRGBA(i420,1920,1080);
return 0;
}
- I420 转 RGB24
- I420转RGB24
- 转YV12为RGB24以及I420转RGB42
- I420转RGB
- YUY2 转 rgb24
- YV12转RGB24
- rgb24转yuv420p
- RGB24转YUV420P
- 关于YUV420转RGB24
- RGB24转jpeg
- rgb24转yuv420
- 平面YUV420转RGB24
- YV12转RGB24
- YV12转RGB24
- i420转opencv的IplImage
- i420转opencv的IplImage
- rgb24转rgb555/rgb565优化
- YUV(YUV422、YUV420) 转RGB24
- bzoj1047[HAOI2007]理想的正方形 单调队列
- papaparse.js读取csv文件在火狐上乱码问题
- 网狐荣耀版系统模块编译出现fatal error c1083:无法打开包含文件“d3d9.h” :no such file or directory
- 练习
- 存储管理
- I420转RGB24
- 【《Real-Time Rendering 3rd》 提炼总结】(八) 第九章 · 全局光照:光线追踪、路径追踪与GI技术进化编年史
- vim 配置文件语法
- Form表单input框设置可编辑与失效(readonly)
- 05-maven私服安装与使用
- MongoDB 数组查询
- android源码中和第三方框架中常见的Builder模式
- codeforces 862A 之 Mahmoud and Ehab and the MEX
- ubuntu 镜像地址 老版 最新版 LTS