Reputation: 317
I want to use the .icc Profile "ISOnewspaper26v4.icc" in C# ! But I have a problem now.. I don't know how to convert CMYK colors to Lab values or RGB to Lab values by using this ICC Profile ??!! How I can assign the profile??
Upvotes: 0
Views: 2414
Reputation: 150
My Unicolour .NET library would be able to help, without any need for wrapping Windows API or LitteCMS functions.
Here's a simple example of how you would use it with the ISOnewspaper26v4.icc
ICC profile:
var isoNewspaper26v4 = new IccConfiguration("./ISOnewspaper26v4.icc", Intent.Perceptual);
var config = new Configuration(iccConfiguration: isoNewspaper26v4);
var magenta = new Unicolour(config, new Channels(0, 1, 0, 0.25)); // CMYK input
Console.WriteLine(magenta.Rgb); // 0.61 0.01 0.34
Console.WriteLine(magenta.Lab); // 33.58 +59.36 -3.47
(Note that LAB values are D65 by default but can easily be configured to be D50)
Upvotes: 0
Reputation: 91
It should be possible to "convert" to CIE Lab with the help of a Lab space ICC profile. AGFA used to have one. Otherwise, one would have to write a routine to manually make the conversion, outside of ICM, through the A2B0 tag, for an output profile. Beware, that ISOnewspaperv4 profile is finacky.
Upvotes: 0
Reputation: 78925
To my knowledge, C# and the associated libraries don't contain any functions for converting CMYK or RGB to Lab. The contain functions for converting CMYK to RGB (see this answer).
The Windows API seems to have functions for converting between different color systems. It at least works for converting RGB to CMYK (see this answer).
You probably need to following extensions:
[StructLayout(LayoutKind.Sequential)]
public struct LabCOLOR
{
public ushort L;
public ushort a;
public ushort b;
public ushort pad;
};
[DllImport("mscms.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
static extern bool TranslateColors(
IntPtr hColorTransform,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), In] RGBColor[] inputColors,
uint nColors,
ColorType ctInput,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] LABColor[] outputColors,
ColorType ctOutput);
Then you should be able to replace "cmyk" with "lab" to convert from RGB to Lab colors. I haven't tried it though.
Upvotes: 0