bmp提取rgb888转换成yuv格式中的yv12再从yv12转换为rgb888写成bmp格式文件的工程,测试通过

bmp中提取rgb888格式的数据 ,转换成yv12格式,
再从yv12格式转换成rgb888格式的数据
然后以bmp格式写入文件的测试工程。

///-------------rgb.cpp-----------内容是rgb与yv12格式转换函数
#include "convert.h"


// Conversion from RGB to YUV420
int RGB2YUV_YR[256], RGB2YUV_YG[256], RGB2YUV_YB[256];
int RGB2YUV_UR[256], RGB2YUV_UG[256], RGB2YUV_UBVR[256];
int RGB2YUV_VG[256], RGB2YUV_VB[256];
// Conversion from YUV420 to RGB24
static long int crv_tab[256];
static long int cbu_tab[256];
static long int cgu_tab[256];
static long int cgv_tab[256];
static long int tab_76309[256];
static unsigned char clp[1024]; //for clip in CCIR601

// Table used for RGB to YUV420 conversion
void InitLookupTable()
{
 int i;
 for (i = 0; i < 256; i++) RGB2YUV_YR[i] = (float)65.481 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_YG[i] = (float)128.553 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_YB[i] = (float)24.966 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_UR[i] = (float)37.797 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_UG[i] = (float)74.203 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_VG[i] = (float)93.786 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_VB[i] = (float)18.214 * (i<<8);
 for (i = 0; i < 256; i++) RGB2YUV_UBVR[i] = (float)112 * (i<<8);
}

// Convert from RGB24 to YUV420
//int ConvertRGB2YUV(int w,int h,unsigned char *bmp,unsigned int *yuv)
int ConvertRGB2YUV(int w,int h,unsigned char *bmp,unsigned char*yuv)
{

 //unsigned int *u,*v,*y,*uu,*vv;
 //unsigned int *pu1,*pu2,*pu3,*pu4;
 //unsigned int *pv1,*pv2,*pv3,*pv4;
 //unsigned char *r,*g,*b;
 //int i,j;

 //uu=new unsigned int[w*h];
 //vv=new unsigned int[w*h];

 unsigned char *u,*v,*y,*uu,*vv;
 unsigned char *pu1,*pu2,*pu3,*pu4;
 unsigned char *pv1,*pv2,*pv3,*pv4;
 unsigned char *r,*g,*b;
 int i,j;

 uu=new unsigned char[w*h];
 vv=new unsigned char[w*h];
 if(uu==NULL || vv==NULL)
  return 0;
 y=yuv;
 u=uu;
 v=vv;
 // Get r,g,b

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值