вот тебе пример преобразования картинки из GRB в YUV
bool DDrawOverlay::render(const QImage & img) {
if (!canRender) return false;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
HRESULT r = lpOverlay->Lock(0, &ddsd,
DDLOCK_WAIT | DDLOCK_WRITEONLY, 0);
if (r != DD_OK)
{
return false;
}
BYTE* surfbits = (BYTE*)ddsd.lpSurface;
WORD* pixptr;
unsigned int* imgBits = (unsigned int*)(img.bits());
int R0,R1, G0,G1, B0,B1;
WORD Y, U, V;
for(int i = 0; i < m_h; i++)
{
pixptr = (WORD*)surfbits;
for (int p = 0; p < m_w; p+=2)
{
R0 = (*imgBits & 0x00FF0000) >> 16;
G0 = (*imgBits & 0x0000FF00) >> 8;
B0 = *imgBits++ & 0x000000FF;
R1 = (*imgBits & 0x00FF0000) >> 16;
G1 = (*imgBits & 0x0000FF00) >> 8;
B1 = *imgBits++ & 0x000000FF;
// U0 Y0 V0 Y1 U2 Y2 V2 Y3 U4 Y4 V4 Y5
U = WORD(((-148*R0 - 291*G0 + 439*B0) >> 10) + 128);
Y = WORD(((257*R0 + 504*G0 + 98*B0) >> 10) + 36) << 8;
V = WORD( ((439*R0 - 368*G0 - 71*B0) >> 10) + 128);
*pixptr++ = U|Y;
Y = WORD(((257*R1 + 504*G1 + 98*B1) >> 10) + 36) << 8;
*pixptr++ = V|Y;
}
surfbits += ddsd.lPitch;
}
lpOverlay->Unlock(0);
return UpdateOverlay();
}