private bool CanSaveInColorSpace(ProfileColorSpace colorSpace) { if (colorSpace != ProfileColorSpace.RGB && colorSpace != ProfileColorSpace.CMYK && colorSpace != ProfileColorSpace.Gray) { ShowErrorMessage(Resources.SaveColorSpaceUnsupportedError); return(false); } return(true); }
void IXmlSerializable.ReadXml(XmlReader reader) { if (reader.MoveToContent() == XmlNodeType.Element) { this.path = reader.GetAttribute("Path"); this.description = reader.GetAttribute("Description"); this.colorSpace = (ProfileColorSpace)Enum.Parse(typeof(ProfileColorSpace), reader.GetAttribute("ColorSpace")); // If the item is part of an array, advance to the next element. if (reader.LocalName == XMLArrayItemName) { reader.Read(); } } }
private PixelFormat GetDestiniationPixelFormat(bool tiff, ProfileColorSpace colorSpace) { PixelFormat destiniationFormat; if (tiff) { switch (colorSpace) { case ProfileColorSpace.CMYK: destiniationFormat = PixelFormats.Cmyk32; break; case ProfileColorSpace.Gray: destiniationFormat = PixelFormats.Gray8; break; case ProfileColorSpace.RGB: destiniationFormat = HasTransparency(this.EffectSourceSurface) ? PixelFormats.Bgra32 : PixelFormats.Bgr24; break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.UnsupportedColorConversionFormat, colorSpace)); } } else { // WIC can encode JPEG images as CMYK according to http://msdn.microsoft.com/en-us/library/windows/desktop/ee719797(v=vs.85).aspx switch (colorSpace) { case ProfileColorSpace.CMYK: destiniationFormat = PixelFormats.Cmyk32; break; case ProfileColorSpace.Gray: destiniationFormat = PixelFormats.Gray8; break; case ProfileColorSpace.RGB: destiniationFormat = PixelFormats.Bgr24; break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.UnsupportedColorConversionFormat, colorSpace)); } } return(destiniationFormat); }
/// <summary> /// Gets the description and color space from the specified color profile. /// </summary> /// <param name="fileName">The path of the color profile.</param> internal static void GetProfileInfo(string fileName, out string description, out ProfileColorSpace colorSpace) { description = "Unknown profile"; colorSpace = ProfileColorSpace.Unknown; using (LCMSProfileHandle hProfile = LCMSHelper.OpenColorProfile(fileName)) { if (!hProfile.IsInvalid) { colorSpace = LCMSHelper.GetProfileColorSpace(hProfile); uint descriptionSize = LCMSHelper.GetProfileInfoSize(hProfile, LCMSEnums.ProfileInfoType.Description); if (descriptionSize > 0U) { description = LCMSHelper.GetProfileInfo(hProfile, LCMSEnums.ProfileInfoType.Description, descriptionSize); } } } }