Rod*_*uss 7 c++ camera directshow bitmap
我正在使用安全摄像头DLL从相机中检索图像.DLL调用我的程序的函数传递图像缓冲区作为参数,但图像是yuy2格式.我需要将此缓冲区转换为RGB,但我尝试了在Internet上找到的每个公式都没有成功.我尝试的每个例子(包括http://msdn.microsoft.com/en-us/library/aa904813(VS.80).aspx#yuvformats_2)都给我错误的颜色.
我只能使用像素的Y分量将缓冲区转换为BW图像,但我真的需要彩色图片.我调试(仅汇编)在屏幕上显示图像的DLL,它使用DirectDraw来执行此操作.
Mar*_*som 12
使用问题中Microsoft链接的信息:
for (int i = 0; i < width/2; ++i)
{
int y0 = ptrIn[0];
int u0 = ptrIn[1];
int y1 = ptrIn[2];
int v0 = ptrIn[3];
ptrIn += 4;
int c = y0 - 16;
int d = u0 - 128;
int e = v0 - 128;
ptrOut[0] = clip(( 298 * c + 516 * d + 128) >> 8); // blue
ptrOut[1] = clip(( 298 * c - 100 * d - 208 * e + 128) >> 8); // green
ptrOut[2] = clip(( 298 * c + 409 * e + 128) >> 8); // red
c = y1 - 16;
ptrOut[3] = clip(( 298 * c + 516 * d + 128) >> 8); // blue
ptrOut[4] = clip(( 298 * c - 100 * d - 208 * e + 128) >> 8); // green
ptrOut[5] = clip(( 298 * c + 409 * e + 128) >> 8); // red
ptrOut += 6;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9040 次 |
| 最近记录: |