首页 > 代码库 > YUV与RGB的相互转换

YUV与RGB的相互转换

YUV到RGB:

int C = Y - 16;
int D = U - 128;
int E = V - 128;

int R = 298 * C           + 409 * E + 128;
int G = 298 * C - 100 * D - 208 * E + 128;
int B = 298 * C + 516 * D           + 128;

RGB到YUV:

int Y = ((66*r + 129*g + 25*b) >> 8) + 16;
int U = ((-38*r + -74*g + 112*b) >> 8) + 128;
int V = ((112*r + -94*g + -18*b) >> 8) + 128;