紧急求助!!!!!!!!!!!!!!!yuvtoRgb程序的源代码(vc6.0环境下)
最近做yuv转rgb.在网上找了几个,始终不成。希望会这个的大哥大姐们能够提供一个参考学习.非常感激
[解决办法]
这个代码你测试一下。应该是可以用的~
void YUV2RGB (LPBYTE yuvBuf,UINT nWidth,UINT nHeight,LPBYTE pRgbBuf)
{
int bmp_wd = nWidth;
int bmp_ht = nHeight;
LPBYTE yBuf , uBuf , vBuf;// Y,U,V分量
short int r, c,R, G, B, y, u, v;
yBuf = yuvBuf;
uBuf = yuvBuf + bmp_wd * bmp_ht;
vBuf = yuvBuf + bmp_wd * bmp_ht * 3/2;
long iIndex=0;
for (r = 0; r < bmp_ht; r++) {
for (c = 0; c < bmp_wd; c++) {
y = yBuf [c];
u = uBuf [c > > 1] - 128;
v = vBuf [c > > 1] - 128;
R = y + 1.375 * v;
G = y - 0.34375 * u - 0.703125 * v;
B = y + 1.734375 * u;
R = max (0, min (255, R));
G = max (0, min (255, G));
B = max (0, min (255, B));
pRgbBuf[iIndex+c+0]=R;
pRgbBuf[iIndex+c+1]=G;
pRgbBuf[iIndex+c+2]=B;
}
yBuf += bmp_wd;
uBuf += bmp_wd/2;
vBuf += bmp_wd/2;
iIndex+=bmp_wd;
}
}