Exemple #1
0
        /// <summary>
        /// Reads an ICC profile from disk
        /// </summary>
        /// <param name="path">Path to the icc file</param>
        public ICC(string path)
        {
            ProfileName = Path.GetFileNameWithoutExtension(path);
            profile     = new ICCProfile(path, true);

            //mediaWhitePointTag
            double[]     wpXYZ = null;
            TagDataEntry wpEn  = profile.GetFirstEntry(TagSignature.mediaWhitePointTag);

            if (wpEn != null && wpEn.Signature == TypeSignature.XYZ)
            {
                wpXYZ = ((XYZTagDataEntry)wpEn).Data[0].GetArray();
            }

            if (wpXYZ != null)
            {
                wp = new Whitepoint(wpXYZ);
            }
            else
            {
                wp = new Whitepoint(Header.PCSIlluminant.GetArray());
            }

            //profileDescriptionTag
            TagDataEntry desc = profile.GetFirstEntry(TagSignature.profileDescriptionTag);

            if (desc.Signature == TypeSignature.multiLocalizedUnicode)
            {
                des = ((multiLocalizedUnicodeTagDataEntry)desc).Text;
            }
            else if (desc.Signature == TypeSignature.text)
            {
                des = new LocalizedString[] { new LocalizedString(new CultureInfo("en"), ((textTagDataEntry)desc).Text) };
            }

            //copyrightTag
            TagDataEntry cpr = profile.GetFirstEntry(TagSignature.copyrightTag);

            if (cpr.Signature == TypeSignature.multiLocalizedUnicode)
            {
                cprs = ((multiLocalizedUnicodeTagDataEntry)cpr).Text;
            }
            else if (cpr.Signature == TypeSignature.text)
            {
                cprs = new LocalizedString[] { new LocalizedString(new CultureInfo("en"), ((textTagDataEntry)cpr).Text) };
            }

            //chromaticAdaptationTag (if data has different reference white as PCS)
            s15Fixed16ArrayTagDataEntry cam = (s15Fixed16ArrayTagDataEntry)profile.GetFirstEntry(TagSignature.chromaticAdaptationTag);

            if (cam != null)
            {
                ma = new double[, ] {
                    { cam.Data[0], cam.Data[1], cam.Data[2] }, { cam.Data[3], cam.Data[4], cam.Data[5] }, { cam.Data[6], cam.Data[7], cam.Data[8] }
                };
                ma1 = MMath.StaticInvertMatrix(ma);
            }

            SetHasVariables();
        }
Exemple #2
0
        /// <summary>
        /// Reads an ICC profile from disk
        /// </summary>
        /// <param name="path">Path to the icc file</param>
        public ICC(string path)
        {
            ProfileName = Path.GetFileNameWithoutExtension(path);
            profile = new ICCProfile(path, true);

            //mediaWhitePointTag
            double[] wpXYZ = null;
            TagDataEntry wpEn = profile.GetFirstEntry(TagSignature.mediaWhitePointTag);
            if (wpEn != null && wpEn.Signature == TypeSignature.XYZ) { wpXYZ = ((XYZTagDataEntry)wpEn).Data[0].GetArray(); }

            if (wpXYZ != null) { wp = new Whitepoint(wpXYZ); }
            else { wp = new Whitepoint(Header.PCSIlluminant.GetArray()); }

            //profileDescriptionTag
            TagDataEntry desc = profile.GetFirstEntry(TagSignature.profileDescriptionTag);
            if (desc.Signature == TypeSignature.multiLocalizedUnicode) { des = ((multiLocalizedUnicodeTagDataEntry)desc).Text; }
            else if (desc.Signature == TypeSignature.text) { des = new LocalizedString[] { new LocalizedString(new CultureInfo("en"), ((textTagDataEntry)desc).Text) }; }

            //copyrightTag
            TagDataEntry cpr = profile.GetFirstEntry(TagSignature.copyrightTag);
            if (cpr.Signature == TypeSignature.multiLocalizedUnicode) { cprs = ((multiLocalizedUnicodeTagDataEntry)cpr).Text; }
            else if (cpr.Signature == TypeSignature.text) { cprs = new LocalizedString[] { new LocalizedString(new CultureInfo("en"), ((textTagDataEntry)cpr).Text) }; }

            //chromaticAdaptationTag (if data has different reference white as PCS)
            s15Fixed16ArrayTagDataEntry cam = (s15Fixed16ArrayTagDataEntry)profile.GetFirstEntry(TagSignature.chromaticAdaptationTag);
            if (cam != null)
            {
                ma = new double[,] { { cam.Data[0], cam.Data[1], cam.Data[2] }, { cam.Data[3], cam.Data[4], cam.Data[5] }, { cam.Data[6], cam.Data[7], cam.Data[8] } };
                ma1 = MMath.StaticInvertMatrix(ma);
            }

            SetHasVariables();
        }
Exemple #3
0
 /// <summary>
 /// Creates a new instance of a CIE LCH Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 /// <param name="L">Lightness (0 - 100)</param>
 /// <param name="C">Chroma</param>
 /// <param name="H">Hue (0 - 360)</param>
 public ColorLCH(Whitepoint ReferenceWhite, double L, double C, double H)
     : base()
 {
     this.wp = ReferenceWhite;
     this.L  = L;
     this.C  = C;
     this.H  = H;
 }
Exemple #4
0
        /// <summary>
        /// Copies this whitepoint to a new whitepoint with the same values
        /// </summary>
        /// <returns>A copy of this whitepoint</returns>
        public Whitepoint Copy()
        {
            Whitepoint p = new Whitepoint(this.Name);

            p.DefCh  = (double[])this.DefCh.Clone();
            p.DefVal = (double[])this.DefVal.Clone();
            return(p);
        }
Exemple #5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Whitepoint c = obj as Whitepoint;

            if ((Object)c == null)
            {
                return(false);
            }

            return(Name == c.Name);
        }
 /// <summary>
 /// Creates an instance of the CIERGB colorspace
 /// </summary>
 public CIERGB()
 {
     wp = new Whitepoint(WhitepointName.E);
 }
        private void SetInputColor(UColor inColor)
        {
            InputModel = inColor.Model;
            DoAdaption = inColor.ReferenceWhite != OutReferenceWhite.Name;
            if (InputModel != ColorModel.Gray)
            {
                ValArr1 = inColor.DoubleColorArray;
                ValArr2 = inColor.DoubleColorArray;
            }
            else
            {
                ValArr1 = new double[] { ((UColorGray)inColor).G / 65535d, 0, 0 };
                ValArr2 = new double[] { ((UColorGray)inColor).G / 65535d, 0, 0 };
            }

            switch (InputModel)
            {
                case ColorModel.CIELab:
                case ColorModel.CIELCHab:
                case ColorModel.CIELCHuv:
                case ColorModel.LCH99:
                case ColorModel.LCH99b:
                case ColorModel.LCH99c:
                case ColorModel.LCH99d:
                case ColorModel.CIELuv:
                case ColorModel.CIEXYZ:
                case ColorModel.CIEYxy:
                case ColorModel.Gray:
                case ColorModel.DEF:
                case ColorModel.Bef:
                case ColorModel.BCH:
                    if (inColor.ReferenceWhite == WhitepointName.Custom || OutReferenceWhite.Name == WhitepointName.Custom) DoAdaption = true;
                    InputWhitepoint = WhitepointArr[(int)inColor.ReferenceWhite];
                    break;

                case ColorModel.HSL:
                    InputRGBSpace = ((UColorHSL)inColor).Space;
                    InputWhitepoint = InputRGBSpace.ReferenceWhite;
                    DoAdaptionRGB();
                    break;
                case ColorModel.HSV:
                    InputRGBSpace = ((UColorHSV)inColor).Space;
                    InputWhitepoint = InputRGBSpace.ReferenceWhite;
                    DoAdaptionRGB();
                    break;
                case ColorModel.RGB:
                    InputRGBSpace = ((UColorRGB)inColor).Space;
                    IsRGBLinear = ((UColorRGB)inColor).IsLinear;
                    InputWhitepoint = InputRGBSpace.ReferenceWhite;
                    DoAdaptionRGB();
                    break;
                case ColorModel.YCbCr:
                    InputRGBSpace = ((UColorYCbCr)inColor).BaseSpace;
                    InputYCbCrSpace = ((UColorYCbCr)inColor).Space;
                    InputWhitepoint = InputRGBSpace.ReferenceWhite;
                    DoAdaptionYCbCr();
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
 /// <summary>
 /// Creates an instance of the PAL_SECAMRGB colorspace
 /// </summary>
 public PAL_SECAMRGB()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
 /// <summary>
 /// Creates an instance of the EktaSpacePS5 colorspace
 /// </summary>
 public EktaSpacePS5()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
 /// <summary>
 /// Creates a new instance of a CIE LCH Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorLCH(Whitepoint ReferenceWhite)
     : this(ReferenceWhite, 0, 0, 0)
 {
 }
 /// <summary>
 /// Creates a new instance of a CIE LCHuv Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorLCHuv(Whitepoint ReferenceWhite)
     : base(ReferenceWhite, 0, 0, 0)
 {
 }
Exemple #12
0
 /// <summary>
 /// Creates an instance of the ITU_R_BT601 colorspace
 /// </summary>
 public ITU_R_BT601_525()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
 /// <summary>
 /// Creates a new instance of a gray Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorGray(Whitepoint ReferenceWhite)
     : this(ReferenceWhite, 0)
 {
 }
 /// <summary>
 /// Converts a color to a HSV color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <param name="colorspace">The colorspace to be used for the converted color</param>
 /// <returns>The converted color</returns>
 public ColorHSV ToHSV(Color InColor, RGBSpaceName colorspace)
 {
     if (colorspace == RGBSpaceName.ICC) throw new ArgumentException("ICC colorspace is not accepted with this method. Use the explicit ICC conversion.");
     OutputModel = ColorModel.HSV;
     RGBSpace = colorspace;
     OutReferenceWhite = WhitepointArr[(int)RGBColorspace.GetWhitepointName(colorspace)];
     SetInputColor(InColor);
     varArr = Do();
     return new ColorHSV(colorspace, varArr[0], varArr[1], varArr[2]);
 }
 /// <summary>
 /// Converts a color to a LCH99c color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <returns>The converted color</returns>
 public ColorLCH99c ToLCH99c(Color InColor)
 {
     OutReferenceWhite = WhitepointArr[(int)WhitepointName.D65];
     OutputModel = ColorModel.LCH99c;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorLCH99c(varArr[0], varArr[1], varArr[2]);
 }
 /// <summary>
 /// Converts a color to a Lab color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <param name="RefWhite">The reference white to be used for the converted color</param>
 /// <returns>The converted color</returns>
 public ColorLab ToLab(Color InColor, WhitepointName RefWhite)
 {
     if (RefWhite != WhitepointName.Custom) OutReferenceWhite = WhitepointArr[(int)RefWhite];
     else OutReferenceWhite = ReferenceWhite;
     OutputModel = ColorModel.CIELab;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorLab(OutReferenceWhite, varArr[0], varArr[1], varArr[2]);
 }
 /// <summary>
 /// Converts a color to a Lab color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <param name="RefWhite">The reference white to be used for the converted color</param>
 /// <returns>The converted color</returns>
 public ColorLab ToLab(Color InColor, Whitepoint RefWhite)
 {
     OutputModel = ColorModel.CIELab;
     OutReferenceWhite = RefWhite;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorLab(OutReferenceWhite, varArr[0], varArr[1], varArr[2]);
 }
 /// <summary> 
 /// Creates an instance of a custom RGB colorspace
 /// </summary>
 /// <param name="xr">X-Chromaticity coordinate for Red</param>
 /// <param name="yr">Y-Chromaticity coordinate for Red</param>
 /// <param name="xg">X-Chromaticity coordinate for Green</param>
 /// <param name="yg">Y-Chromaticity coordinate for Green</param>
 /// <param name="xb">X-Chromaticity coordinate for Blue</param>
 /// <param name="yb">Y-Chromaticity coordinate for Blue</param>
 /// <param name="Gamma">The gamme value</param>
 /// <param name="ReferenceWhite">The reference white</param>
 public CustomRGB(double xr, double yr, double xg, double yg, double xb, double yb, double Gamma, Whitepoint ReferenceWhite)
 {
     wp = ReferenceWhite;
     this.gamma = Gamma;
     this.xr = xr;
     this.yr = yr;
     this.xg = xg;
     this.yg = yg;
     this.xb = xb;
     this.yb = yb;
     _CM = GetM();
     _ICM = MMath.StaticInvertMatrix(_CM);
 }
 /// <summary>
 /// Creates a new instance of a gray Color
 /// </summary>
 /// <param name="G">The value of the gray</param>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorGray(Whitepoint ReferenceWhite, double G)
     : base()
 {
     this.G  = G;
     this.wp = ReferenceWhite;
 }
 /// <summary>
 /// Converts a color to a HSV color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <returns>The converted color</returns>
 public ColorHSV ToHSV(Color InColor)
 {
     OutputModel = ColorModel.HSV;
     RGBSpace = StandardColorspace;
     OutReferenceWhite = ReferenceWhite;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorHSV(RGBSpace, varArr[0], varArr[1], varArr[2]);
 }
 /// <summary>
 /// Creates an instance of the ITU_R_BT709 colorspace
 /// </summary>
 public ITU_R_BT709_1250()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
Exemple #22
0
 /// <summary>
 /// Creates an instance of the ITU_R_BT709 colorspace
 /// </summary>
 public ITU_R_BT709_1250()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
 /// <summary>
 /// Creates an instance of the ITU_R_BT601 colorspace
 /// </summary>
 public ITU_R_BT601_525()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
 /// <summary>
 /// Creates a new instance of a CIE LCHuv Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 /// <param name="L">Lightness (0 - 100)</param>
 /// <param name="C">Chroma</param>
 /// <param name="H">Hue (0 - 360)</param>
 public ColorLCHuv(Whitepoint ReferenceWhite, double L, double C, double H)
     : base(ReferenceWhite, L, C, H)
 {
 }
 /// <summary>
 /// Creates an instance of the SMPTE_C_RGB colorspace
 /// </summary>
 public SMPTE_C_RGB()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
 /// <summary>
 /// Creates a new instance of a CIE LCH Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 /// <param name="L">Lightness (0 - 100)</param>
 /// <param name="C">Chroma</param>
 /// <param name="H">Hue (0 - 360)</param>
 public ColorLCH(Whitepoint ReferenceWhite, double L, double C, double H)
     : base()
 {
     this.wp = ReferenceWhite;
     this.L = L;
     this.C = C;
     this.H = H;
 }
 /// <summary>
 /// Creates an instance of the WideGamutRGB colorspace
 /// </summary>
 public WideGamutRGB()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
 /// <summary>
 /// Creates an instance of the NTSCRGB colorspace
 /// </summary>
 public NTSCRGB()
 {
     wp = new Whitepoint(WhitepointName.C);
 }
 /// <summary>
 /// Creates an instance of the BetaRGB colorspace
 /// </summary>
 public BetaRGB()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
 /// <summary>
 /// Creates an instance of the ProPhotoRGB colorspace
 /// </summary>
 public ProPhotoRGB()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
        private void SetFastReferenceWhite(Whitepoint RefWhite, RGBSpaceName colorspace)
        {
            switch (OutputModel)
            {
                case ColorModel.CIEXYZ:
                case ColorModel.CIEYxy:
                case ColorModel.CIELab:
                case ColorModel.CIELuv:
                case ColorModel.CIELCHab:
                case ColorModel.CIELCHuv:
                case ColorModel.LCH99:
                case ColorModel.LCH99b:
                case ColorModel.LCH99c:
                case ColorModel.LCH99d:
                case ColorModel.DEF:
                case ColorModel.Bef:
                case ColorModel.BCH:
                case ColorModel.Gray:
                    OutReferenceWhite = RefWhite;
                    break;

                case ColorModel.RGB:
                case ColorModel.HSV:
                case ColorModel.HSL:
                case ColorModel.YCbCr:
                    OutReferenceWhite = WhitepointArr[(int)RGBColorspace.GetWhitepointName(StandardColorspace)];
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
 /// <summary>
 /// Creates an instance of the sRGB colorspace
 /// </summary>
 public sRGB()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
Exemple #33
0
 /// <summary>
 /// Creates a new instance of a CIE LCH Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorLCH(Whitepoint ReferenceWhite)
     : this(ReferenceWhite, 0, 0, 0)
 {
 }
 /// <summary>
 /// Creates an instance of the AdobeRGB colorspace
 /// </summary>
 public AdobeRGB()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
Exemple #35
0
 /// <summary>
 /// Creates a new instance of a CIE LCHuv Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 public ColorLCHuv(Whitepoint ReferenceWhite)
     : base(ReferenceWhite, 0, 0, 0)
 {
 }
 /// <summary>
 /// Creates an instance of the BruceRGB colorspace
 /// </summary>
 public BruceRGB()
 {
     wp = new Whitepoint(WhitepointName.D65);
 }
Exemple #37
0
 /// <summary>
 /// Creates a new instance of a CIE LCHuv Color
 /// </summary>
 /// <param name="ReferenceWhite">The reference white</param>
 /// <param name="L">Lightness (0 - 100)</param>
 /// <param name="C">Chroma</param>
 /// <param name="H">Hue (0 - 360)</param>
 public ColorLCHuv(Whitepoint ReferenceWhite, double L, double C, double H)
     : base(ReferenceWhite, L, C, H)
 {
 }
 /// <summary>
 /// Creates an instance of the ColorMatchRGB colorspace
 /// </summary>
 public ColorMatchRGB()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
 /// <summary>
 /// Copies this whitepoint to a new whitepoint with the same values
 /// </summary>
 /// <returns>A copy of this whitepoint</returns>
 public Whitepoint Copy()
 {
     Whitepoint p = new Whitepoint(this.Name);
     p.DefCh = (double[])this.DefCh.Clone();
     p.DefVal = (double[])this.DefVal.Clone();
     return p;
 }
 /// <summary>
 /// Creates an instance of the DonRGB4 colorspace
 /// </summary>
 public DonRGB4()
 {
     wp = new Whitepoint(WhitepointName.D50);
 }
 /// <summary>
 /// Converts a color to a gray color
 /// </summary>
 /// <param name="InColor">The color to convert</param>
 /// <param name="RefWhite">The reference white to be used for the converted color</param>
 /// <returns>The converted color</returns>
 public ColorGray ToGray(Color InColor, WhitepointName RefWhite)
 {
     if (RefWhite != WhitepointName.Custom) OutReferenceWhite = WhitepointArr[(int)RefWhite];
     else OutReferenceWhite = ReferenceWhite;
     OutputModel = ColorModel.Gray;
     SetInputColor(InColor);
     varArr = Do();
     return new ColorGray(OutReferenceWhite, varArr[0]);
 }