Skip to content

jrshoare/lcmsNET

Repository files navigation

lcmsNET

GitHub license Build status lcmsNET on fuget.org

.NET bindings for Little CMS (http://www.littlecms.com/)

Requirements

The following software is required if you want only to use this library:

The following applications are needed to build this library:

To use on Windows, make sure that lcms2.dll is in the DLL search path, e.g. the PATH environment variable.

To use on Linux see the API Reference documentation on the Little CMS web site for installation instructions.

This library is available as a NuGet package too.

How to build

To build this library you need to install the .NET Core SDK.

To build the library, run the following command in the project folder:

dotnet build -c Release

A successful build will put the resulting library in

..\..\bin\netstandard2.0

How to use

To use this library in your project add the following statement to your source code:

using lcmsNET;

Print Little CMS library version

Console.WriteLine(Cms.EncodedCMMVersion);

Set error handler

void HandleError(IntPtr contextID, int errorCode, string errorText)
{
    // do something with the error, e.g. log it to file
}

Cms.SetErrorHandler(HandleError);

...

// restore default error handler
Cms.SetErrorHandler(null);

Open a profile for reading

using (var profile = Profile.Open(profilePath, "r"))
{
    // do something with the profile
}

Create and use a transform

using (var input = Profile.Open(inputProfilePath, "r"))
using (var output = Profile.Open(outputProfilePath, "r"))
using (var transform = Transform.Create(input, Cms.TYPE_RGB_8, output, Cms.TYPE_RGB_8,
        Intent.Perceptual, CmsFlags.None))
{
    byte[] source = ....
    byte[] dest = new byte[source.Length];
    transform.DoTransform(source, dest, pixelCount);
}

Other

See the unit tests for examples of how to invoke each supported method and property.

Future work