c#使用ICC配置文件将CMYK颜色转换为Cielab或RGB转换为Cielab

时间:2013-02-07 11:53:08

标签: c# colors rgb cmyk color-profile

我想使用.icc Profile" ISOnewspaper26v4.icc"在C#中! 但我现在有一个问题..我不知道如何通过使用此ICC配置文件将CMYK颜色转换为Lab值或RGB转换为Lab值!!我如何分配个人资料?

2 个答案:

答案 0 :(得分:0)

据我所知,C#和相关库不包含任何将CMYK或RGB转换为Lab的功能。包含将CMYK转换为RGB的函数(请参阅此answer)。

Windows API似乎具有在不同颜色系统之间进行转换的功能。它至少适用于将RGB转换为CMYK(请参阅此answer)。

您可能需要关注以下内容:

    [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);

然后您应该能够将“cmyk”替换为“lab”以将RGB转换为Lab颜色。我没试过。

答案 1 :(得分:0)

应该可以借助Lab space ICC配置文件“转换”到CIE Lab。 AGFA曾经有一个。否则,必须编写一个例程,通过A2B0标记在ICM之外手动进行转换,以获得输出配置文件。请注意,ISOnewspaperv4配置文件是非常狡猾的。