www.pudn.com > yuv2bmp.rar > YUV2RGB.cpp
#include "stdafx.h"
//yuv->bmp
//输入:yuvin-yuv图像数据, width-图像像素宽度, height-图像像素高度
//输出:rgbout-bmp图像数据
void yuv2bmp(unsigned char *rgbout, const unsigned char *yuvin, int width, int height)
{
int col,row;
long Y,U,V;
long red,blue,green;
for (row=0; row>1;
Y=yuvin[rowptr+col];
U=yuvin[rowptr+colhalf+width*height-row*width/2];
V=yuvin[rowptr+colhalf+width*height-row*width/2+width*height/2];
red=(int)(Y+(U-128)*1.375);
green=(int)(Y-(U-128)*0.34375-(V-128)*0.703125);
blue=(int)(Y+(V-128)*1.734375);
if (red>255) red=255;
else if (red<0) red=0;
if (green>255) green=255;
else if (green<0) green=0;
if (blue>255) blue=255;
else if (blue<0) blue=0;
rgbout[idx++]=(char)red;
rgbout[idx++]=(char)green;
rgbout[idx++]=(char)blue;
}
}
}