AForge.Imaging.YCbCr.ToRGB C# (CSharp) Method

ToRGB() public static method

Convert from YCbCr to RGB color space.
public static ToRGB ( YCbCr ycbcr, RGB rgb ) : void
ycbcr YCbCr Source color in YCbCr color space.
rgb RGB Destination color in RGB color spacs.
return void
        public static void ToRGB( YCbCr ycbcr, RGB rgb )
        {
            // don't warry about zeros. compiler will remove them
            float r = Math.Max( 0.0f, Math.Min( 1.0f, (float) ( ycbcr.Y + 0.0000 * ycbcr.Cb + 1.4022 * ycbcr.Cr ) ) );
            float g = Math.Max( 0.0f, Math.Min( 1.0f, (float) ( ycbcr.Y - 0.3456 * ycbcr.Cb - 0.7145 * ycbcr.Cr ) ) );
            float b = Math.Max( 0.0f, Math.Min( 1.0f, (float) ( ycbcr.Y + 1.7710 * ycbcr.Cb + 0.0000 * ycbcr.Cr ) ) );

            rgb.Red   = (byte) ( r * 255 );
            rgb.Green = (byte) ( g * 255 );
            rgb.Blue  = (byte) ( b * 255 );
            rgb.Alpha = 255;
        }

Same methods

YCbCr::ToRGB ( ) : RGB