public static ColorProfile GetDestProfile(ColorProfile prof, ColorProfileMode mode) { if (mode == ColorProfileMode.Preserve) { return(prof); } if (mode <= ColorProfileMode.NormalizeAndEmbed) { if (prof == AdobeRgb || prof.DataColorSpace == ProfileColorSpace.Cmyk) { return(AdobeRgb); } if (prof.ProfileType == ColorProfileType.Curve) { return(sGrey); } if (!(prof is MatrixProfile mp) || isWideGamut(mp.Matrix)) { return(DisplayP3); } } return(prof.ProfileType == ColorProfileType.Curve ? sGrey : sRGB);
public static ColorProfile GetSourceProfile(ColorProfile prof, ColorProfileMode mode) { if (mode == ColorProfileMode.Preserve) { return(prof); } if (prof.ProfileType == ColorProfileType.Curve && prof is CurveProfile cp && cp.Curve == sGrey.Curve) { return(sGrey); } if (prof is MatrixProfile mp) { if (mp.Matrix.IsRouglyEqualTo(sRGB.Matrix) && mp.Curve == sRGB.Curve) { return(sRGB); } if (mp.Matrix.IsRouglyEqualTo(DisplayP3.Matrix) && mp.Curve == DisplayP3.Curve) { return(DisplayP3); } if (mp.Matrix.IsRouglyEqualTo(AdobeRgb.Matrix) && mp.Curve == AdobeRgb.Curve) { return(AdobeRgb); } } return(prof); }