private void DuaICCProfile_Data_Data(ILGenerator CMIL, ICCProfile profile1, ICCProfile profile2) { if (profile1.PCS == profile2.PCS) { TempColor1 = profile1.GetPCSColor(true); var c1 = new ConversionCreator_ICC(CMIL, Data, InColor, TempColor1, false); c1.SetConversionMethod(); var c2 = new ConversionCreator_ICC(c1, TempColor1, OutColor, true); c1.SetConversionMethod(); } else { TempColor1 = profile1.GetPCSColor(true); TempColor2 = profile2.GetPCSColor(true); var c1 = new ConversionCreator_ICC(CMIL, Data, InColor, TempColor1, false); c1.SetConversionMethod(); var c2 = new ConversionCreator_Color(c1, TempColor1, TempColor2, false); c2.SetConversionMethod(); var c3 = new ConversionCreator_ICC(c2, TempColor2, OutColor, true); c3.SetConversionMethod(); } }
/// <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(); }
/// <summary> Construct a header from a complete ICCProfile</summary> /// <param name="byte">[] -- holds ICCProfile contents /// </param> public ICCProfileHeader(byte[] data) { dwProfileSize = ICCProfile.getInt(data, offProfileSize); dwCMMTypeSignature = ICCProfile.getInt(data, offCMMTypeSignature); dwProfileClass = ICCProfile.getInt(data, offProfileClass); dwColorSpaceType = ICCProfile.getInt(data, offColorSpaceType); dwPCSType = ICCProfile.getInt(data, offPCSType); dwProfileSignature = ICCProfile.getInt(data, offProfileSignature); dwPlatformSignature = ICCProfile.getInt(data, offPlatformSignature); dwCMMFlags = ICCProfile.getInt(data, offCMMFlags); dwDeviceManufacturer = ICCProfile.getInt(data, offDeviceManufacturer); dwDeviceModel = ICCProfile.getInt(data, offDeviceModel); dwDeviceAttributes1 = ICCProfile.getInt(data, offDeviceAttributesReserved); dwDeviceAttributesReserved = ICCProfile.getInt(data, offDeviceAttributesReserved); dwRenderingIntent = ICCProfile.getInt(data, offRenderingIntent); dwCreatorSig = ICCProfile.getInt(data, offCreatorSig); profileVersion = ICCProfile.getICCProfileVersion(data, offProfileVersion); dateTime = ICCProfile.getICCDateTime(data, offDateTime); PCSIlluminant = ICCProfile.getXYZNumber(data, offPCSIlluminant); for (int i = 0; i < reserved.Length; ++i) { reserved[i] = data[offReserved + i]; } }
/// <summary> Ctor used by factory method.</summary> /// <param name="byte">raw tag data /// </param> protected internal ICCTagTable(byte[] data) { tagCount = ICCProfile.getInt(data, offTagCount); int offset = offTags; for (int i = 0; i < tagCount; ++i) { int signature = ICCProfile.getInt(data, offset); int tagOffset = ICCProfile.getInt(data, offset + ICCProfile.int_size); int length = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size); trios.Add(new Triplet(signature, tagOffset, length)); offset += 3 * ICCProfile.int_size; } System.Collections.IEnumerator Enum = trios.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" while (Enum.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" Triplet trio = (Triplet)Enum.Current; ICCTag tag = ICCTag.createInstance(trio.signature, data, trio.offset, trio.count); System.Object tempObject; tempObject = this[(System.Int32)tag.signature]; this[(System.Int32)tag.signature] = tag; System.Object generatedAux2 = tempObject; } }
private async void OpenButton_Click(object sender, EventArgs e) { string title = Title; try { OpenButton.Enabled = false; using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filters.Add(new FileDialogFilter("ICC Profile", ".icc", ".icm")); dlg.Filters.Add(new FileDialogFilter("All Files", ".*")); var res = dlg.ShowDialog(this); if (res == DialogResult.Ok) { ProfilePath = dlg.FileName; PathTextBox.Text = ProfilePath; Title += " - Opening Profile"; await Task.Run(() => { Profile = Reader.Read(ProfilePath); }); SetHeaderUI(); SetTagTableUI(); } } } catch (CorruptProfileException cex) { MessageBox.Show(cex.Message, "Profile Error", MessageBoxButtons.OK); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } finally { OpenButton.Enabled = true; Title = title; } }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id</param> /// <param name="data">array of bytes</param> /// <param name="offset">to data in the data array</param> /// <param name="length">of data in the data array</param> protected internal ICCSignatureType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size) { type = ICCProfile.getInt(data, offset); reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size); signature = ICCProfile.getInt(data, offset + ICCProfile.int_size); }
//byte[] Data; /// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id</param> /// <param name="data">array of bytes</param> /// <param name="offset">to data in the data array</param> /// <param name="length">of data in the data array</param> protected internal ICCDataType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size) { type = ICCProfile.getInt(data, offset); reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size); dataFlag = ICCProfile.getInt(data, offset + ICCProfile.int_size); //Data = ICCProfile.getString(data, offset + ICCProfile.int_size, length, true); }
/// <summary> Ued by subclass initialization to store the state common to all tags</summary> /// <param name="signature">tag being created /// </param> /// <param name="data">byte array containg embedded tag data /// </param> /// <param name="offset">to tag data in the array /// </param> /// <param name="count">size of tag data in bytes /// </param> protected internal ICCTag(int signature, byte[] data, int offset, int count) { this.signature = signature; this.data = data; this.offset = offset; this.count = count; this.type = ICCProfile.getInt(data, offset); }
private void DuaICCProfile_PCS_PCS(ILGenerator CMIL, ICCProfile profile1, ICCProfile profile2) { //PCS1 == PCS2 will result in an assign //PCS1 != PCS2 will result in a conversion var c = new ConversionCreator_Color(CMIL, Data, InColor, OutColor); c.SetConversionMethod(); }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id</param> /// <param name="data">array of bytes</param> /// <param name="offset">to data in the data array</param> /// <param name="length">of data in the data array</param> protected internal ICCViewType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size) { type = ICCProfile.getInt(data, offset); reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size); CIEilluminant = ICCProfile.getXYZNumber(data, offset + ICCProfile.int_size); CIEsurround = ICCProfile.getXYZNumber(data, offset + (ICCProfile.int_size * 3)); illuminant = ICCProfile.getInt(data, offset + (ICCProfile.int_size * 3)); }
/// <summary>Return the string rep of this tag. </summary> public override System.String ToString() { System.Text.StringBuilder rep = new System.Text.StringBuilder("[").Append(base.ToString()).Append(eol); rep.Append("num entries = " + System.Convert.ToString(nEntries) + eol); rep.Append("data length = " + System.Convert.ToString(entry_Renamed_Field.Length) + eol); for (int i = 0; i < nEntries; ++i) { rep.Append(ICCProfile.toHexString(entry_Renamed_Field[i]) + eol); } return(rep.Append("]").ToString()); }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id</param> /// <param name="data">array of bytes</param> /// <param name="offset">to data in the data array</param> /// <param name="length">of data in the data array</param> protected internal ICCMeasurementType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size) { type = ICCProfile.getInt(data, offset); reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size); observer = ICCProfile.getInt(data, offset + ICCProfile.int_size); backing = ICCProfile.getXYZNumber(data, offset + ICCProfile.int_size); geometry = ICCProfile.getInt(data, offset + (ICCProfile.int_size * 3)); flare = ICCProfile.getInt(data, offset + ICCProfile.int_size); illuminant = ICCProfile.getInt(data, offset + ICCProfile.int_size); }
/// <summary>Write to a file. </summary> //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'" public virtual void write(System.IO.FileStream raf) { byte[] xb = ICCProfile.setLong(x); byte[] yb = ICCProfile.setLong(y); byte[] zb = ICCProfile.setLong(z); // CONVERSION PROBLEM? raf.Write(xb, ICCProfile.int_size, 0); raf.Write(yb, ICCProfile.int_size, 0); raf.Write(zb, ICCProfile.int_size, 0); }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id /// </param> /// <param name="data">array of bytes /// </param> /// <param name="offset">to data in the data array /// </param> /// <param name="length">of data in the data array /// </param> protected internal ICCCurveType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, offset + 2 * ICCProfile.int_size) { type = ICCProfile.getInt(data, offset); reserved = ICCProfile.getInt(data, offset + ICCProfile.int_size); nEntries = ICCProfile.getInt(data, offset + 2 * ICCProfile.int_size); entry_Renamed_Field = new int[nEntries]; for (int i = 0; i < nEntries; ++i) { entry_Renamed_Field[i] = ICCProfile.getShort(data, offset + 3 * ICCProfile.int_size + i * ICCProfile.short_size) & 0xFFFF; } }
private void Menu_ICCOpen_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "ICC Profile(*.icc)|*.icc"; if (openFileDialog.ShowDialog() == true) { ICCProfile profile = new ICCProfile(); profile.Read(openFileDialog.FileName); MessageBox.Show(profile.Header.ProfileSize.ToString()); } }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id /// </param> /// <param name="data">array of bytes /// </param> /// <param name="offset">to data in the data array /// </param> /// <param name="length">of data in the data array /// </param> protected internal ICCTextDescriptionType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length) { type = ICCProfile.getInt(data, offset); offset += ICCProfile.int_size; reserved = ICCProfile.getInt(data, offset); offset += ICCProfile.int_size; size = ICCProfile.getInt(data, offset); offset += ICCProfile.int_size; ascii = new byte[size - 1]; Array.Copy(data, offset, ascii, 0, size - 1); }
/// <summary> Factory method for creating a tag of a specific type.</summary> /// <param name="signature">tag to create /// </param> /// <param name="data">byte array containg embedded tag data /// </param> /// <param name="offset">to tag data in the array /// </param> /// <param name="count">size of tag data in bytes /// </param> /// <returns> specified ICCTag /// </returns> public static ICCTag createInstance(int signature, byte[] data, int offset, int count) { int type = ICCProfile.getInt(data, offset); if (type == kdwTextDescType) { return(new ICCTextDescriptionType(signature, data, offset, count)); } else if (type == kdwTextType) { return(new ICCTextType(signature, data, offset, count)); } else if (type == kdwXYZType) { return(new ICCXYZType(signature, data, offset, count)); } else if (type == kdwXYZTypeReverse) { return(new ICCXYZTypeReverse(signature, data, offset, count)); } else if (type == kdwCurveType) { return(new ICCCurveType(signature, data, offset, count)); } else if (type == kdwCurveTypeReverse) { return(new ICCCurveTypeReverse(signature, data, offset, count)); } else if (type == kdwMeasurementType) { return(new ICCMeasurementType(signature, data, offset, count)); } else if (type == kdwSignatureType) { return(new ICCSignatureType(signature, data, offset, count)); } else if (type == kdwViewType) { return(new ICCViewType(signature, data, offset, count)); } else if (type == kdwDataType) { return(new ICCDataType(signature, data, offset, count)); } else { throw new System.ArgumentException("bad tag type: " + System.Text.ASCIIEncoding.ASCII.GetString(BitConverter.GetBytes(type)) + "(" + type + ")"); } }
/// <summary> Construct this tag from its constituant parts</summary> /// <param name="signature">tag id /// </param> /// <param name="data">array of bytes /// </param> /// <param name="offset">to data in the data array /// </param> /// <param name="length">of data in the data array /// </param> protected internal ICCTextType(int signature, byte[] data, int offset, int length) : base(signature, data, offset, length) { type = ICCProfile.getInt(data, offset); offset += ICCProfile.int_size; reserved = ICCProfile.getInt(data, offset); offset += ICCProfile.int_size; int size = 0; while (data[offset + size] != 0) { ++size; } ascii = new byte[size]; Array.Copy(data, offset, ascii, 0, size); }
private void CheckColorTypeICC(ICCProfile profile) { _ICCProfile = profile; _IsICCPCS = profile.PCSType == GetType(); _IsICCDataSpace = profile.DataColorspaceType == GetType(); if (profile.Class == ProfileClassName.DeviceLink && !IsICCDataSpace) { throw new ColorTypeException("Color with Device Link profile has to be the ICC profiles DataColorspace type."); } else if (profile.Class == ProfileClassName.Abstract && !IsICCPCS) { throw new ColorTypeException("Color with Abstract profile has to be the ICC profiles PCS type."); } else if (!IsICCPCS && !IsICCDataSpace) { throw new ColorTypeException("Color is neither of PCS or DataColorspace type of ICC profile"); } _IsColorICC = true; }
/// <summary> /// Creates a new instance of the <see cref="ColorGray"/> class /// </summary> /// <param name="G">Value for the Gray channel</param> /// <param name="profile">The ICC profile for this color</param> public ColorGray(double G, ICCProfile profile) : base(new ColorspaceICC(profile), G) { }
/// <summary> /// Creates a new instance of the <see cref="ColorGray"/> class /// </summary> /// <param name="profile">The ICC profile for this color</param> public ColorGray(ICCProfile profile) : base(new ColorspaceICC(profile), 0) { }
/// <summary> /// Creates a new instance of the <see cref="ColorX"/> class /// </summary> /// <param name="profile">The ICC profile for this color</param> /// <param name="values">The values for this color (Length Max=15, Min=2)</param> public ColorX(ICCProfile profile, params double[] values) : base(new ColorspaceICC(profile), values) { InitArrays(); }
/// <summary> /// Creates a new instance of the <see cref="ColorX"/> class /// </summary> /// <param name="profile">The ICC profile for this color</param> /// <param name="channelCount">The number of channels for this color (Max=15, Min=2)</param> public ColorX(ICCProfile profile, int channelCount) : base(new ColorspaceICC(profile), new double[channelCount]) { InitArrays(); }
/// <summary> /// Creates a new instance of the <see cref="ColorXYZ"/> class /// </summary> /// <param name="profile">The ICC profile for this color</param> public ColorXYZ(ICCProfile profile) : base(new ColorspaceICC(profile), 0, 0, 0) { }
/// <summary> /// Creates a new instance of the <see cref="ColorCMY"/> class /// </summary> /// <param name="C">Value for the Cyan channel</param> /// <param name="M">Value for the Magenta channel</param> /// <param name="Y">Value for the Yellow channel</param> /// <param name="profile">The ICC profile for this color</param> public ColorCMY(double C, double M, double Y, ICCProfile profile) : base(new ColorspaceICC(profile), C, M, Y) { }
/// <summary> /// Creates a new instance of the <see cref="ColorHSx"/> class /// </summary> /// <param name="H">Value for the Hue channel</param> /// <param name="S">Value for the Saturation channel</param> /// <param name="x">Value for the X channel</param> /// <param name="profile">The ICC profile for this color</param> protected ColorHSx(double H, double S, double x, ICCProfile profile) : base(new ColorspaceICC(profile), H, S, x) { }
/// <summary> /// Creates a new instance of the <see cref="ColorLuv"/> class /// </summary> /// <param name="L">Value for the Lightness channel</param> /// <param name="u">Value for the u channel</param> /// <param name="v">Value for the v channel</param> /// <param name="profile">The ICC profile for this color</param> public ColorLuv(double L, double u, double v, ICCProfile profile) : base(new ColorspaceICC(profile), L, u, v) { }
/// <summary> /// Creates a new instance of the <see cref="ColorRGB"/> class /// </summary> /// <param name="R">Value for the Red channel</param> /// <param name="G">Value for the Green channel</param> /// <param name="B">Value for the Blue channel</param> /// <param name="profile">The ICC profile for this color</param> public ColorRGB(double R, double G, double B, ICCProfile profile) : base(new ColorspaceICC(profile), R, G, B) { }
/// <summary> /// Creates a new instance of the <see cref="ColorXYZ"/> class /// </summary> /// <param name="X">Value for the X channel</param> /// <param name="Y">Value for the Y channel</param> /// <param name="Z">Value for the Z channel</param> /// <param name="profile">The ICC profile for this color</param> public ColorXYZ(double X, double Y, double Z, ICCProfile profile) : base(new ColorspaceICC(profile), X, Y, Z) { }
/// <summary> /// Creates a new instance of the <see cref="ColorHSx"/> class /// </summary> /// <param name="profile">The ICC profile for this color</param> protected ColorHSx(ICCProfile profile) : base(new ColorspaceICC(profile), 0, 0, 0) { }