private void ReadData() { try { TagData = new TagDataEntry[TagTable.TagCount]; for (int j = 0; j < TagTable.TagCount; j++) { TagData[j] = TagDataEntry.CreateEntry(TagTable.Data[j], Header); } } catch (Exception ex) { throw new CorruptProfileException("Profile is corrupt", ex); } }
/// <summary> /// Get the all entries with the specific signature /// </summary> /// <param name="TagName">The signature of the entry</param> /// <returns>The array of data of the named entry</returns> public TagDataEntry[] GetAllEntries(TagSignature TagName) { TagTableEntry[] Entries = TagTable.Data.Where(t => t.Signature == TagName).ToArray(); if (Entries.Length != 0) { TagDataEntry[] output = new TagDataEntry[Entries.Length]; for (int i = 0; i < Entries.Length; i++ ) { output[i] = TagData[Entries[i].Index]; } return output; } else { return null; } }
private double[] PCS_Multiprocess_PCS() { TagEntry1 = Profile.GetEntry(TagSignature.DToB0Tag); AdjustColor(); return ((multiProcessElementsTagDataEntry)TagEntry1).GetValue(ic); }
private static void GetCurve(int Offset, ref TagDataEntry[] data, int idx, int InputChannelCount) { //Signature (4 bytes + 4 bytes reserved) TypeSignature t = (TypeSignature)Helper.GetUInt32(Offset); if (t != TypeSignature.curve && t != TypeSignature.parametricCurve) { throw new CorruptProfileException("lutAToBTagDataEntry"); } //Curve data = new TagDataEntry[InputChannelCount]; int end = idx + Offset; for (int i = 0; i < InputChannelCount; i++) { if (t == TypeSignature.curve) { data[i] = new curveTagDataEntry(end); end = ((curveTagDataEntry)data[i]).end; } else if (t == TypeSignature.parametricCurve) { data[i] = new parametricCurveTagDataEntry(idx); end = ((parametricCurveTagDataEntry)data[i]).end; } end += (end % 4) + 8; } }
private double[] PCS_MatrixTRC_Device() { output = new double[3]; AdjustColor(); if (ic.Length != 3) { throw new ArgumentException("Input color has wrong number of channels"); } if (InModel != ColorModel.CIEXYZ) { throw new ArgumentException("Profile connection space has to be XYZ"); } Mr = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.redMatrixColumnTag)).Data[0].GetArray(); Mg = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.greenMatrixColumnTag)).Data[0].GetArray(); Mb = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.blueMatrixColumnTag)).Data[0].GetArray(); M = new double[3, 3] { { Mr[0], Mg[0], Mb[0] }, { Mr[1], Mg[1], Mb[1] }, { Mr[2], Mg[2], Mb[2] } }; t = mmath.MultiplyMatrix(mmath.InvertMatrix(M), ic); TagEntry1 = Profile.GetEntry(TagSignature.redTRCTag); if (TagEntry1.Signature == TypeSignature.curve) { output[0] = ((curveTagDataEntry)TagEntry1).GetValueInverted(t[0]); } else if (TagEntry1.Signature == TypeSignature.parametricCurve) { output[0] = ((parametricCurveTagDataEntry)TagEntry1).Curve.InverseFunction(t[0]); } else { throw new CorruptProfileException("redTRCTag has wrong type"); } TagEntry2 = Profile.GetEntry(TagSignature.greenTRCTag); if (TagEntry2.Signature == TypeSignature.curve) { output[1] = ((curveTagDataEntry)TagEntry2).GetValueInverted(t[1]); } else if (TagEntry2.Signature == TypeSignature.parametricCurve) { output[1] = ((parametricCurveTagDataEntry)TagEntry2).Curve.InverseFunction(t[1]); } else { throw new CorruptProfileException("greenTRCTag has wrong type"); } TagEntry3 = Profile.GetEntry(TagSignature.blueTRCTag); if (TagEntry3.Signature == TypeSignature.curve) { output[2] = ((curveTagDataEntry)TagEntry3).GetValueInverted(t[2]); } else if (TagEntry3.Signature == TypeSignature.parametricCurve) { output[2] = ((parametricCurveTagDataEntry)TagEntry3).Curve.InverseFunction(t[2]); } else { throw new CorruptProfileException("blueTRCTag has wrong type"); } return output; }
private double[] PCS_Multiprocess_Device() { AdjustColor(); if (ic.Length != 3) { throw new ArgumentException("Input color has wrong number of channels"); } if (InModel != ColorModel.CIEXYZ && InModel != ColorModel.CIELab) { throw new ArgumentException("Profile connection space has to be either XYZ or Lab"); } if (PreferredRenderingIntent == RenderingIntent.RelativeColorimetric) { sig = TagSignature.BToD1Tag; } else if (PreferredRenderingIntent == RenderingIntent.Saturation) { sig = TagSignature.BToD2Tag; } else if (PreferredRenderingIntent == RenderingIntent.AbsoluteColorimetric) { sig = TagSignature.BToD3Tag; } else { sig = TagSignature.BToD0Tag; } TagEntry1 = Profile.GetEntry(sig); if (TagEntry1 == null) { TagEntry1 = Profile.GetEntry(TagSignature.BToD0Tag); } return ((multiProcessElementsTagDataEntry)TagEntry1).GetValue(ic); }
private double[] PCS_LUT_Device() { AdjustColor(); if (ic.Length != 3) { throw new ArgumentException("Input color has wrong number of channels"); } if (InModel != ColorModel.CIEXYZ && InModel != ColorModel.CIELab) { throw new ArgumentException("Profile connection space has to be either XYZ or Lab"); } if (PreferredRenderingIntent == RenderingIntent.RelativeColorimetric) { sig = TagSignature.BToA1Tag; } else if (PreferredRenderingIntent == RenderingIntent.Saturation) { sig = TagSignature.BToA2Tag; } else { sig = TagSignature.BToA0Tag; } TagEntry1 = Profile.GetEntry(sig); if (TagEntry1 == null) { TagEntry1 = Profile.GetEntry(TagSignature.BToA0Tag); } if (TagEntry1.Signature == TypeSignature.lut8) { output = ((lut8TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lut16) { output = ((lut16TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lutBToA) { output = ((lutBToATagDataEntry)TagEntry1).GetValue(ic); } else { throw new CorruptProfileException("BToATag has wrong type"); } return output; }
private double[] PCS_LUT_PCS() { TagEntry1 = Profile.GetEntry(TagSignature.AToB0Tag); AdjustColor(); if (TagEntry1.Signature == TypeSignature.lut8) { output = ((lut8TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lut16) { output = ((lut16TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lutAToB) { output = ((lutAToBTagDataEntry)TagEntry1).GetValue(ic); } else { throw new CorruptProfileException("AToBTag has wrong type"); } return output; }
private double[] PCS_Gray_Device() { if (Profile.Header.PCS == ColorSpaceType.CIEXYZ) { sic = InValues[1]; } else if (Profile.Header.PCS == ColorSpaceType.CIELAB) { sic = InValues[0] / 100d; } else { throw new ArgumentException("Profile connection space is corrupt! (has to be either XYZ or Lab)"); } output = new double[1]; TagEntry1 = Profile.GetEntry(TagSignature.grayTRCTag); if (TagEntry1.Signature == TypeSignature.curve) { output[0] = ((curveTagDataEntry)TagEntry1).GetValueInverted(sic); } else if (TagEntry1.Signature == TypeSignature.parametricCurve) { output[0] = ((parametricCurveTagDataEntry)TagEntry1).Curve.InverseFunction(sic); } else { throw new CorruptProfileException("grayTRCTag has wrong type"); } return output; }
private double[] Device_Multiprocess_PCS() { if (PreferredRenderingIntent == RenderingIntent.RelativeColorimetric) { sig = TagSignature.DToB1Tag; } else if (PreferredRenderingIntent == RenderingIntent.Saturation) { sig = TagSignature.DToB2Tag; } else if (PreferredRenderingIntent == RenderingIntent.AbsoluteColorimetric) { sig = TagSignature.DToB3Tag; } else { sig = TagSignature.DToB0Tag; } TagEntry1 = Profile.GetEntry(sig); if (TagEntry1 == null) { TagEntry1 = Profile.GetEntry(TagSignature.DToB0Tag); } AdjustColor(); return ((multiProcessElementsTagDataEntry)TagEntry1).GetValue(ic); }
private double[] Device_MatrixTRC_PCS() { t = new double[3]; AdjustColor(); if (ic.Length != 3) { throw new ArgumentException("Input color has wrong number of channels"); } TagEntry1 = Profile.GetEntry(TagSignature.redTRCTag); if (TagEntry1.Signature == TypeSignature.curve) { t[0] = ((curveTagDataEntry)TagEntry1).GetValue(ic[0]); } else if (TagEntry1.Signature == TypeSignature.parametricCurve) { t[0] = ((parametricCurveTagDataEntry)TagEntry1).Curve.Function(ic[0]); } else { throw new CorruptProfileException("redTRCTag has wrong type"); } TagEntry2 = Profile.GetEntry(TagSignature.greenTRCTag); if (TagEntry2.Signature == TypeSignature.curve) { t[1] = ((curveTagDataEntry)TagEntry2).GetValue(ic[1]); } else if (TagEntry2.Signature == TypeSignature.parametricCurve) { t[1] = ((parametricCurveTagDataEntry)TagEntry2).Curve.Function(ic[1]); } else { throw new CorruptProfileException("greenTRCTag has wrong type"); } TagEntry3 = Profile.GetEntry(TagSignature.blueTRCTag); if (TagEntry3.Signature == TypeSignature.curve) { t[2] = ((curveTagDataEntry)TagEntry3).GetValue(ic[2]); } else if (TagEntry3.Signature == TypeSignature.parametricCurve) { t[2] = ((parametricCurveTagDataEntry)TagEntry3).Curve.Function(ic[2]); } else { throw new CorruptProfileException("blueTRCTag has wrong type"); } Mr = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.redMatrixColumnTag)).Data[0].GetArray(); Mg = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.greenMatrixColumnTag)).Data[0].GetArray(); Mb = ((XYZTagDataEntry)Profile.GetEntry(TagSignature.blueMatrixColumnTag)).Data[0].GetArray(); M = new double[3, 3] { { Mr[0], Mg[0], Mb[0] }, { Mr[1], Mg[1], Mb[1] }, { Mr[2], Mg[2], Mb[2] } }; return mmath.MultiplyMatrix(M, t); }
private double[] Device_LUT_PCS() { AdjustColor(); if (PreferredRenderingIntent == RenderingIntent.RelativeColorimetric) { sig = TagSignature.AToB1Tag; } else if (PreferredRenderingIntent == RenderingIntent.Saturation) { sig = TagSignature.AToB2Tag; } else { sig = TagSignature.AToB0Tag; } TagEntry1 = Profile.GetEntry(sig); if (TagEntry1 == null) { TagEntry1 = Profile.GetEntry(TagSignature.AToB0Tag); } if (TagEntry1.Signature == TypeSignature.lut8) { output = ((lut8TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lut16) { output = ((lut16TagDataEntry)TagEntry1).GetValue(ic); } else if (TagEntry1.Signature == TypeSignature.lutAToB) { output = ((lutAToBTagDataEntry)TagEntry1).GetValue(ic); } else { throw new CorruptProfileException("AToBTag has wrong type"); } return output; }
private Color Device_Gray_PCS() { TagEntry1 = Profile.GetEntry(TagSignature.grayTRCTag); if (TagEntry1.Signature == TypeSignature.curve) { sout = ((curveTagDataEntry)TagEntry1).GetValue(InValues[0]); } else if (TagEntry1.Signature == TypeSignature.parametricCurve) { sout = ((parametricCurveTagDataEntry)TagEntry1).Curve.Function(InValues[0]); } else { throw new CorruptProfileException("grayTRCTag has wrong type"); } if (Profile.Header.PCS == ColorSpaceType.CIEXYZ) { return new ColorXYZ(Profile.ReferenceWhite, 0, sout, 0); } else if (Profile.Header.PCS == ColorSpaceType.CIELAB) { return new ColorLab(Profile.ReferenceWhite, sout * 100, 0, 0); } else { throw new ArgumentException("Profile connection space is corrupt! (has to be either XYZ or Lab)"); } }