Browse Source

Update comments

pull/2922/head
James Jackson-South 1 year ago
parent
commit
65bb20bbb4
  1. 9
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs
  2. 7
      src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs

9
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs

@ -73,11 +73,10 @@ internal abstract partial class JpegColorConverterBase
// do not implement transforms from it.
// Therefore, we first convert JPEG YCbCr to RGB manually, then perform
// color-managed conversion to the target profile.
// TODO: The initial YCbCr => RGB conversion is assumed to be in the sRGB working space.
// To perform accurate colorimetric conversion via XYZ, we should derive the working space
// from the source ICC profile (e.g., via header/tags).
// This is a placeholder until that logic is implemented.
//
// The YCbCr => RGB conversion is based on BT.601 and is independent of any embedded ICC profile.
// Since the same RGB working space is used during conversion to and from XYZ,
// colorimetric accuracy is preserved.
ColorProfileConverter converter = new();
PackedNormalizeInterleave3(c0, c1, c2, packed, 1F / maxValue);

7
src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs

@ -104,10 +104,9 @@ internal abstract partial class JpegColorConverterBase
// ICC profiles expect colorimetric CMYK values, so we must first convert YccK to CMYK using a hardcoded inverse transform.
// This transform assumes Rec.601 YCbCr coefficients and an inverted K channel.
//
// TODO: The intermediate YccK => RGB step assumes a working space with sRGB primaries and D65 white point.
// To perform accurate colorimetric conversion via XYZ, we should derive the working space
// from the source ICC profile (e.g., via header/tags).
// This is a placeholder until that logic is implemented.
// The YccK => Cmyk conversion is independent of any embedded ICC profile.
// Since the same RGB working space is used during conversion to and from XYZ,
// colorimetric accuracy is preserved.
converter.Convert<YccK, Cmyk>(MemoryMarshal.Cast<Cmyk, YccK>(source), source);
Span<Rgb> destination = MemoryMarshal.Cast<float, Rgb>(packed)[..source.Length];

Loading…
Cancel
Save