Microsoft Windows CE 3.0  

Converting Between YUV and RGB

This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

It is frequently necessary to convert between YUV pixel formats (used by the JPEG and MPEG compression methods) and RGB format (used by many hardware manufacturers.) The following formulas show how to compute a pixel's value in one format from the pixel value in the other format.

YUV format allows for higher compression rates without a proportionately high loss of data, as the U and V portions can be highly compressed and computed from the non- or lowly-compressed Y portion.

Computing YUV from RGB

Y = 0.3R + 0.6G + 0.1B U = B - Y V = R - Y


Y = 0.3R + 0.6G + 0.1B U = -0.3R - 0.6G + 0.9B V
= 0.7R - 0.6G - 0.1B

Computing RGB from YUV

R = Y + V G = Y - 0.166667U - 0.5V B = Y +
Note   All units range from 0 (zero) to 1.0 (one). In DirectDraw, they range from 0 to 255. Overflow and underflow can (and does) occur, and the results must be saturated.

 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.