|
|
|
@ -29,6 +29,9 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.YCbCr |
|
|
|
float cb = input.Cb - 128F; |
|
|
|
float cr = input.Cr - 128F; |
|
|
|
|
|
|
|
float r = MathF.Round(y + (1.402F * cr), MidpointRounding.AwayFromZero); |
|
|
|
float g = MathF.Round(y - (0.344136F * cb) - (0.714136F * cr), MidpointRounding.AwayFromZero); |
|
|
|
float b = MathF.Round(y + (1.772F * cb), MidpointRounding.AwayFromZero); |
|
|
|
|
|
|
|
return new Rgb(new Vector3(r, g, b) / MaxBytes); |
|
|
|
} |
|
|
|
@ -45,8 +48,10 @@ namespace ImageSharp.ColorSpaces.Conversion.Implementation.YCbCr |
|
|
|
float b = rgb.Z; |
|
|
|
|
|
|
|
float y = (0.299F * r) + (0.587F * g) + (0.114F * b); |
|
|
|
float cb = 128F + ((-0.168736F * r) - (0.331264F * g) + (0.5F * b)); |
|
|
|
float cr = 128F + ((0.5F * r) - (0.418688F * g) - (0.081312F * b)); |
|
|
|
|
|
|
|
return new YCbCr(y, cb, cr); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |