/// <summary> /// Creates a new instance of the <see cref="Transform"/> class for a multiprofile transform. /// </summary> /// <param name="context">A <see cref="Context"/>, or null for the global context.</param> /// <param name="profiles">An array of profiles.</param> /// <param name="inputFormat">The input format, e.g., <see cref="Cms.TYPE_RGB_8"/>.</param> /// <param name="outputFormat">The output format, e.g. <see cref="Cms.TYPE_Lab_8"/>.</param> /// <param name="intent">The intent.</param> /// <param name="flags">The flags to control the process.</param> /// <returns>A new <see cref="Transform"/> instance.</returns> /// <exception cref="LcmsNETException"> /// Failed to create instance. /// </exception> /// <remarks> /// <para> /// Creates the instance in the global context if <paramref name="context"/> is null. /// </para> /// </remarks> public static Transform Create(Context context, Profile[] profiles, uint inputFormat, uint outputFormat, Intent intent, CmsFlags flags) { return(new Transform(Interop.CreateMultiprofileTransform(context?.Handle ?? IntPtr.Zero, profiles.Select(_ => _.Handle).ToArray(), inputFormat, outputFormat, Convert.ToUInt32(intent), Convert.ToUInt32(flags)), context)); }
public void FlagsTest() { // Arrange var tempPath = Path.Combine(Path.GetTempPath(), "lcmsNET.Tests"); Directory.CreateDirectory(tempPath); try { var srgbpath = Path.Combine(tempPath, "srgb.icc"); Save(".Resources.sRGB.icc", srgbpath); var labpath = Path.Combine(tempPath, "lab.icc"); Save(".Resources.Lab.icc", labpath); using (var srgb = Profile.Open(srgbpath, "r")) using (var lab = Profile.Open(labpath, "r")) using (var transform = Transform.Create(srgb, Cms.TYPE_RGB_8, lab, Cms.TYPE_Lab_8, Intent.Perceptual, CmsFlags.NoOptimize | CmsFlags.BlackPointCompensation)) { // Act CmsFlags actual = transform.Flags; // Assert // transform creation may add or remove flags so do not assert equality with values passed to create method } } catch (EntryPointNotFoundException) { Assert.Inconclusive("Requires Little CMS 2.12 or later."); } finally { Directory.Delete(tempPath, true); } }
public void CreateExtendedTest() { // Arrange var tempPath = Path.Combine(Path.GetTempPath(), "lcmsNET.Tests"); Directory.CreateDirectory(tempPath); IntPtr plugin = IntPtr.Zero; IntPtr userData = IntPtr.Zero; try { var srgbpath = Path.Combine(tempPath, "srgb.icc"); Save(".Resources.sRGB.icc", srgbpath); // Act Profile[] profiles = new Profile[1]; bool[] bpc = new bool[] { true }; Intent[] intents = new Intent[] { Intent.RelativeColorimetric }; double[] adaptationStates = new double[] { 1.0 }; Profile gamut = null; int gamutPCSPosition = 0; uint inputFormat = Cms.TYPE_RGB_8; uint outputFormat = Cms.TYPE_XYZ_16; CmsFlags flags = CmsFlags.None; using (var context = Context.Create(plugin, userData)) using (profiles[0] = Profile.Open(srgbpath, "r")) using (var transform = Transform.Create(context, profiles, bpc, intents, adaptationStates, gamut, gamutPCSPosition, inputFormat, outputFormat, flags)) { // Assert Assert.IsNotNull(transform); } } finally { Directory.Delete(tempPath, true); } }
/// <summary> /// Creates a new instance of the <see cref="Transform"/> class. /// </summary> /// <param name="context">A <see cref="Context"/>, or null for the global context.</param> /// <param name="input">A profile capable to work in the input direction.</param> /// <param name="inputFormat">The input format, e.g., <see cref="Cms.TYPE_RGB_8"/>.</param> /// <param name="output">A profile capable to work in the output direction.</param> /// <param name="outputFormat">The output format, e.g. <see cref="Cms.TYPE_Lab_8"/>.</param> /// <param name="intent">The intent.</param> /// <param name="flags">The flags to control the process.</param> /// <returns>A new <see cref="Transform"/> instance.</returns> /// <exception cref="LcmsNETException"> /// Failed to create instance. /// </exception> /// <remarks> /// <para> /// Creates the instance in the global context if <paramref name="context"/> is null. /// </para> /// </remarks> public static Transform Create(Context context, Profile input, uint inputFormat, Profile output, uint outputFormat, Intent intent, CmsFlags flags) { return(new Transform(Interop.CreateTransform(context?.Handle ?? IntPtr.Zero, input.Handle, inputFormat, output.Handle, outputFormat, Convert.ToUInt32(intent), Convert.ToUInt32(flags)), context)); }
/// <summary> /// Creates a new instance of the <see cref="Transform"/> class. /// </summary> /// <param name="input">A profile capable to work in the input direction.</param> /// <param name="inputFormat">The input format, e.g., <see cref="Cms.TYPE_RGB_8"/>.</param> /// <param name="output">A profile capable to work in the output direction.</param> /// <param name="outputFormat">The output format, e.g. <see cref="Cms.TYPE_Lab_8"/>.</param> /// <param name="intent">The intent.</param> /// <param name="flags">The flags to control the process.</param> /// <returns>A new <see cref="Transform"/> instance.</returns> /// <exception cref="LcmsNETException"> /// Failed to create instance. /// </exception> /// <remarks> /// <para> /// Creates the instance in the global context. /// </para> /// </remarks> public static Transform Create(Profile input, uint inputFormat, Profile output, uint outputFormat, Intent intent, CmsFlags flags) { return(new Transform(Interop.CreateTransform(input.Handle, inputFormat, output.Handle, outputFormat, Convert.ToUInt32(intent), Convert.ToUInt32(flags)))); }
/// <summary> /// Creates a new instance of the <see cref="Transform"/> class for a multiprofile transform /// exposing all parameters for each profile in the chain. /// </summary> /// <param name="context">A <see cref="Context"/>, or null for the global context.</param> /// <param name="profiles">An array of profiles.</param> /// <param name="bpc">An array of black point compensation states.</param> /// <param name="intents">An array of intents.</param> /// <param name="adaptationStates">An array of adaptation states.</param> /// <param name="gamut">A profile holding gamut information for a gamut check, can be null.</param> /// <param name="gamutPCSPosition">Position in the chain of Lab/XYZ PCS to check gamut.</param> /// <param name="inputFormat">The input format, e.g., <see cref="Cms.TYPE_RGB_8"/>.</param> /// <param name="outputFormat">The output format, e.g. <see cref="Cms.TYPE_XYZ_16"/>.</param> /// <param name="flags">The flags to control the process.</param> /// <returns>A new <see cref="Transform"/> instance.</returns> /// <exception cref="LcmsNETException"> /// Failed to create instance. /// </exception> /// <remarks> /// <para> /// <paramref name="gamut"/> and <paramref name="gamutPCSPosition"/> are only used if /// <paramref name="flags"/> includes <see cref="CmsFlags.GamutCheck"/>. /// </para> /// <para> /// Creates the instance in the global context if <paramref name="context"/> is null. /// </para> /// </remarks> public static Transform Create(Context context, Profile[] profiles, bool[] bpc, Intent[] intents, double[] adaptationStates, Profile gamut, int gamutPCSPosition, uint inputFormat, uint outputFormat, CmsFlags flags) { return(new Transform(Interop.CreateExtendedTransform(context?.Handle ?? IntPtr.Zero, profiles.Select(_ => _.Handle).ToArray(), bpc.Select(_ => _ ? 1 : 0).ToArray(), intents.Select(_ => Convert.ToUInt32(_)).ToArray(), adaptationStates, gamut?.Handle ?? IntPtr.Zero, gamutPCSPosition, inputFormat, outputFormat, Convert.ToUInt32(flags)), context)); }