/// <summary> /// Creates a new instance of a CMY color /// </summary> /// <param name="profile">The icc profile</param> /// <param name="C">Cyan value (0.0 - 100.0)</param> /// <param name="M">Magenta value (0.0 - 100.0)</param> /// <param name="Y">Yellow value (0.0 - 100.0)</param> public ColorCMY(ICC profile, double C, double M, double Y) : base(profile) { this.C = C; this.M = M; this.Y = Y; }
/// <summary> /// Creates a new instance of a color /// </summary> /// <param name="profile">The ICC profile for this color</param> protected Color(ICC profile) { if (ICC_Converter.IsSameSpace(Model, profile.Header.DataColorspace)) { IsPCScolor = false; } else if (ICC_Converter.IsSameSpace(Model, profile.Header.PCS)) { IsPCScolor = true; } else { throw new ArgumentException("Profile device space or PCS has to be the same as this color"); } ICC_Profile = profile; ColorValues = new double[ChannelCount]; }
/// <summary> /// Converts the PCS color into the device color /// </summary> /// <param name="Profile">The profile that will be used for the conversion</param> /// <param name="pcs">The PCS color (has to match the profiles PCS color type)</param> /// <param name="PrefRenderingIntent">The preferred rendering intent</param> /// <returns>The converted color in the device color type</returns> public Color ToDevice(ICC Profile, Color pcs, RenderingIntent PrefRenderingIntent) { InValues = pcs.ColorArray; InModel = pcs.Model; this.Profile = Profile; PreferredRenderingIntent = PrefRenderingIntent; IsDefault = true; return Do_PCS(); }
/// <summary> /// Creates a new instance of a CMY color /// </summary> /// <param name="profile">The icc profile</param> public ColorCMY(ICC profile) : this(profile, 0, 0, 0) { }
/// <summary> /// Creates a new instance of a CMYK color /// </summary> /// <param name="profile">The icc profile</param> /// <param name="C">Cyan value (0.0 - 100.0)</param> /// <param name="M">Magenta value (0.0 - 100.0)</param> /// <param name="Y">Yellow value (0.0 - 100.0)</param> /// <param name="K">Key (Black) value (0.0 - 100.0)</param> public ColorCMYK(ICC profile, double C, double M, double Y, double K) : base(profile, C, M, Y) { this.K = K; }
/// <summary> /// Converts the PCS color into the device color /// </summary> /// <param name="Profile">The profile that will be used for the conversion</param> /// <param name="pcs">The PCS color (has to match the profiles PCS color type)</param> /// <param name="ConversionMethod">The method of conversion</param> /// <param name="ConversionType">The type of conversion</param> /// <returns>The converted color in the device color type</returns> public Color ToDevice(ICC Profile, Color pcs, ICCconversionMethod ConversionMethod, ICCconversionType ConversionType) { InValues = pcs.ColorArray; InModel = pcs.Model; this.Profile = Profile; PreferredRenderingIntent = ColorConverter.PreferredRenderingIntent; this.ConversionMethod = ConversionMethod; this.ConversionType = ConversionType; IsDefault = false; return Do_PCS(); }
/// <summary> /// Creates a new instance of a X-Channel Color /// </summary> /// <param name="profile">The ICC profile for this color</param> public ColorX(ICC profile) : base(profile) { SetValues(profile.Header.DataColorspace); }
private void Space_CoBox_SelectedIndexChanged(object sender, EventArgs e) { bool en = false; ICC nICC = null; if (((RGBSpaceName)((ComboBox)sender).SelectedIndex) == RGBSpaceName.ICC) { if (((ComboBox)sender).Name != General_SpaceDrDo.Name) { iccOpenDialog.InitialDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "Profiles"); iccOpenDialog.Title = "Choose ICC for " + ((ComboBox)sender).Name.Substring(0, ((ComboBox)sender).Name.IndexOf('_')); if (iccOpenDialog.ShowDialog() == DialogResult.OK) { en = true; nICC = new ICC(iccOpenDialog.FileName); } else { ((ComboBox)sender).SelectedIndex = PrevSpace; } } } else { en = false; } SetICCStuff(en, nICC, ((ComboBox)sender).Name); PrevSpace = ((ComboBox)sender).SelectedIndex; }
private void ChooseICC_Click(object sender, EventArgs e) { bool en = false; ICC nICC = null; iccOpenDialog.InitialDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "Profiles"); iccOpenDialog.Title = "Choose ICC for " + ((Button)sender).Name.Substring(0, ((Button)sender).Name.IndexOf('_')); if (iccOpenDialog.ShowDialog() == DialogResult.OK) { en = true; nICC = new ICC(iccOpenDialog.FileName); } SetICCStuff(en, nICC, ((Button)sender).Name); }
private Color ToICCcolor(Color InColor, ICC profile) { switch (profile.Header.PCS) { case ICCReader.ColorSpaceType.CIELAB: return ToLab(InColor, profile.ReferenceWhite); case ICCReader.ColorSpaceType.CIELUV: return ToLuv(InColor, profile.ReferenceWhite); case ICCReader.ColorSpaceType.CIEXYZ: return ToXYZ(InColor, profile.ReferenceWhite); case ICCReader.ColorSpaceType.CIEYxy: return ToYxy(InColor, profile.ReferenceWhite); case ICCReader.ColorSpaceType.Gray: return ToGray(InColor, profile.ReferenceWhite); case ICCReader.ColorSpaceType.HLS: return ToHSL(InColor); case ICCReader.ColorSpaceType.HSV: return ToHSV(InColor); case ICCReader.ColorSpaceType.RGB: return ToRGB(InColor); case ICCReader.ColorSpaceType.YCbCr: return ToYCbCr(InColor); default: throw new ArgumentException("Cannot convert"); } }
/// <summary> /// Converts a color to the ICC PCS color /// </summary> /// <param name="InColor">The color to convert</param> /// <param name="profile">The profile the color should converted to</param> /// <returns>The converted color</returns> public Color ToICC_PCS(Color InColor, ICC profile) { if (InColor.ICCprofile != null) { if (InColor.IsPCScolor) { return ToICCcolor(InColor, profile); } //directly convert to profile.PCS else { return ToICC_PCS(ToICC(InColor), profile); } //convert with InColor.icc to InColor.PCS, from InColor.PCS to profile.PCS } else { return ToICCcolor(InColor, profile); } //directly convert to profile.PCS }
/// <summary> /// Converts a color to the ICC color /// </summary> /// <param name="InColor">The color to convert</param> /// <param name="profile">The icc file to be used for the conversion</param> /// <param name="ConversionType">The type of conversion</param> /// <param name="ConversionMethod">The method of conversion</param> /// <param name="PrefRenderingIntent">The preferred rendering intent</param> /// <returns>The converted color</returns> public Color ToICC(Color InColor, ICC profile, RenderingIntent PrefRenderingIntent, ICCconversionType ConversionType, ICCconversionMethod ConversionMethod) { if (ICC_Converter.IsSameSpace(InColor.Model, profile.Header.DataColorspace)) { return ICCconverter.ToPCS(profile, InColor, PrefRenderingIntent, ConversionMethod, ConversionType); } else if (ICC_Converter.IsSameSpace(InColor.Model, profile.Header.PCS)) { return ICCconverter.ToDevice(profile, InColor, PrefRenderingIntent, ConversionMethod, ConversionType); } else { return ToICC(ToICC_PCS(InColor, profile), profile, PrefRenderingIntent, ConversionType, ConversionMethod); } }
/// <summary> /// Converts a color to the ICC color /// </summary> /// <param name="InColor">The color to convert</param> /// <param name="profile">The icc file to be used for the conversion</param> /// <returns>The converted color</returns> public Color ToICC(Color InColor, ICC profile) { if (ICC_Converter.IsSameSpace(InColor.Model, profile.Header.DataColorspace)) { return ICCconverter.ToPCS(profile, InColor); } else if (ICC_Converter.IsSameSpace(InColor.Model, profile.Header.PCS)) { return ICCconverter.ToDevice(profile, InColor); } else { return ToICC(ToICC_PCS(InColor, profile), profile); } }
/// <summary> /// Creates a new instance of a gray Color /// </summary> /// <param name="profile">The ICC profile for this color</param> public ColorGray(ICC profile) : base(profile) { }
/// <summary> /// Creates a new instance of a gray Color /// </summary> /// <param name="profile">The ICC profile for this color</param> /// <param name="G">The value of the gray</param> public ColorGray(ICC profile, double G) : base(profile) { this.G = G; }
private void LoadICC(bool From, bool IsRGB) { ICC nICC = null; iccOpenDialog.InitialDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "Profiles"); iccOpenDialog.Title = "Choose ICC"; if (iccOpenDialog.ShowDialog() == DialogResult.OK) { nICC = new ICC(iccOpenDialog.FileName); } else { if (From) { if (IsRGB) ColorspaceFromDroDo.SelectedIndex = PrevFromSpace; else YCbCrSpaceFromDroDo.SelectedIndex = PrevYCbCrFromSpace; ICCboxFrom.Text = String.Empty; } else { if (IsRGB) ColorspaceToDroDo.SelectedIndex = PrevToSpace; else YCbCrSpaceToDroDo.SelectedIndex = PrevYCbCrToSpace; ICCboxTo.Text = String.Empty; } } if (nICC != null) { if (From) { if (IsRGB) { FromICC = nICC; ICCboxFrom.Text = nICC.ProfileName; } else { FromYCbCrICC = nICC; ICCYCbCrFromBox.Text = nICC.ProfileName; } } else { if (IsRGB) { ToICC = nICC; ICCboxTo.Text = nICC.ProfileName; } else { ToYCbCrICC = nICC; ICCYCbCrToBox.Text = nICC.ProfileName; } } } }
/// <summary> /// Converts the device color into the PCS color /// </summary> /// <param name="Profile">The profile that will be used for the conversion</param> /// <param name="inColor">The device color (has to match the profiles device color type)</param> /// <param name="PrefRenderingIntent">The preferred rendering intent</param> /// <returns>The converted color in the PCS color type</returns> public Color ToPCS(ICC Profile, Color inColor, RenderingIntent PrefRenderingIntent) { InValues = inColor.ColorArray; InModel = inColor.Model; this.Profile = Profile; PreferredRenderingIntent = PrefRenderingIntent; IsDefault = true; return Do_Device(); }
private void SetICCStuff(bool Enabled, ICC nICC, string Name) { switch (Name) { case "General_SpaceDrDo": if (IsInit) { foreach (ComboBox c in SpaceCoBoxes) { if (c.Name != General_SpaceDrDo.Name) c.SelectedIndex = (int)BaseSpace; else ColorConverter.StandardColorspace = BaseSpace; } } break; case "RGB_CoBox": RGB_ICCbox.Enabled = Enabled; RGB_ICC = nICC; RGB_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "HSL_CoBox": HSL_ICCbox.Enabled = Enabled; HSL_ICC = nICC; HSL_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "HSV_CoBox": HSV_ICCbox.Enabled = Enabled; HSV_ICC = nICC; HSV_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "YCbCr_CoBox": YCbCr_ICCbox.Enabled = Enabled; YCbCr_ICC = nICC; YCbCr_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "CMY_ChICC": CMY_ICCbox.Enabled = Enabled; CMY_ICC = nICC; CMY_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "CMYK_ChICC": CMYK_ICCbox.Enabled = Enabled; CMYK_ICC = nICC; CMYK_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "Gray_ChICC": Gray_ICCbox.Enabled = Enabled; Gray_ICC = nICC; Gray_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; case "ColorX_ChICC": XColor_ICCbox.Enabled = Enabled; XColor_ICC = nICC; XColor_ICCbox.Text = (nICC == null) ? String.Empty : nICC.ProfileName; break; } }
/// <summary> /// Converts the device color into the PCS color /// </summary> /// <param name="Profile">The profile that will be used for the conversion</param> /// <param name="inColor">The device color (has to match the profiles device color type)</param> /// <param name="PrefRenderingIntent">The preferred rendering intent</param> /// <param name="ConversionMethod">The method of conversion</param> /// <param name="ConversionType">The type of conversion</param> /// <returns>The converted color in the PCS color type</returns> public Color ToPCS(ICC Profile, Color inColor, RenderingIntent PrefRenderingIntent, ICCconversionMethod ConversionMethod, ICCconversionType ConversionType) { InValues = inColor.ColorArray; InModel = inColor.Model; this.Profile = Profile; PreferredRenderingIntent = PrefRenderingIntent; this.ConversionMethod = ConversionMethod; this.ConversionType = ConversionType; IsDefault = false; return Do_Device(); }
private void YCbCr_CoBox_SelectedIndexChanged(object sender, EventArgs e) { bool en = false; ICC nICC = null; if (((YCbCrSpaceName)((ComboBox)sender).SelectedIndex) == YCbCrSpaceName.ICC) { iccOpenDialog.InitialDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "Profiles"); iccOpenDialog.Title = "Choose ICC for YCbCr"; if (iccOpenDialog.ShowDialog() == DialogResult.OK) { en = true; nICC = new ICC(iccOpenDialog.FileName); } else { ((ComboBox)sender).SelectedIndex = PrevSpace; } } else { en = false; } SetICCStuff(en, nICC, ((ComboBox)sender).Name); PrevYCbCrSpace = YCbCr_CoBox.SelectedIndex; }
/// <summary> /// Creates a new instance of a X-Channel Color /// </summary> /// <param name="profile">The ICC profile for this color</param> /// <param name="Channels">The values for each channel (2 to 15)</param> public ColorX(ICC profile, params double[] Channels) : base(profile) { SetValues(profile.Header.DataColorspace); if (ChannelCount != Channels.Length) { throw new ArgumentException("Profile-space and channel-values do not match (wrong channelcount)"); } ColorValues = Channels; }