il YUV è un formato un po' rompi.. però ti do una chicca:
codice:
int CalculateRGB(WORD red, WORD green, WORD blue, WORD* pixel, bool U)
{
unsigned int Rc, Gc, Bc, Rx, Bx;
Rc = ((WORD)red * 77) / 256;
Gc = ((WORD)green * 150) / 256;
Bc = ((WORD)blue * 29) / 256;
Rx = ((WORD)red * 180) / 256;
Bx = ((WORD)blue * 227) / 256;
unsigned int Y = Rc + Bc + Gc;
unsigned int CR = Rx - Gc - Bc + 128;
unsigned int CB = Bx - Gc - Rc + 128;
if(Y > 255) Y = 255;
if(CR > 255) CR = 255;
if(CB > 255) CB = 255;
if(CR < 0) CR = 0;
if(Y < 0) Y = 0;
if(CB < 0) CB = 0;
BYTE* b = (BYTE*)pixel;
if(U)
{
b[0] = Y;
b[1] = CR;
}
else
{
b[0] = Y;
b[1] = CB;
}
return 0;
}
il booleano U serve per calcolare sia il YUV che il YUY2.. usa false per il YUV (mi pare)
da questa formula puoi facilmente fare la cosa oppoeta.. da un YUV ad un RGB