lcms2-dotnet
2.19.1
dotnet add package lcms2-dotnet --version 2.19.1
NuGet\Install-Package lcms2-dotnet -Version 2.19.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="lcms2-dotnet" Version="2.19.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="lcms2-dotnet" Version="2.19.1" />
<PackageReference Include="lcms2-dotnet" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add lcms2-dotnet --version 2.19.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: lcms2-dotnet, 2.19.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package lcms2-dotnet@2.19.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=lcms2-dotnet&version=2.19.1
#tool nuget:?package=lcms2-dotnet&version=2.19.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
lcms2-dotnet
lcms2-dotnet are .NET bindings for lcms2.
Usage
using Lcms2;
using var srgb = IccProfile.CreateSrgb();
using var display = IccProfile.Open("/usr/share/color/icc/display.icc");
using var transform = ColorTransform.Create(
srgb, PixelFormat.Rgb8,
display, PixelFormat.Rgb8,
RenderingIntent.Perceptual,
TransformFlags.BlackPointCompensation);
transform.Transform<byte, byte>(source, destination, pixelCount);
using var profile = IccProfile.FromStream(File.OpenRead("input.icc"));
Console.WriteLine(profile.Description);
Console.WriteLine($"{profile.ColorSpace} → {profile.ProfileConnectionSpace}, v{profile.Version}");
foreach (var tag in profile.GetTagSignatures())
{
Console.WriteLine(tag);
}
var whitePoint = profile.ReadXyz(Lcms2.Native.cmsTagSignature.cmsSigMediaWhitePointTag);
var redTrc = profile.ReadToneCurve(Lcms2.Native.cmsTagSignature.cmsSigRedTRCTag);
using var gamma = ToneCurve.BuildGamma(2.2);
ColorMath.TryGetWhitePointFromTemperature(6504, out var d65);
using var profile = IccProfile.CreateRgb(d65, primaries, [gamma, gamma, gamma]);
using var description = Mlu.Create("My RGB space", "en", "US");
profile.WriteTag(cmsTagSignature.cmsSigProfileDescriptionTag, description);
profile.ComputeProfileId();
profile.SaveToFile("my-space.icc");
var format = PixelFormat.Create(PixelType.Cmyk, channels: 4, bytesPerChannel: 2, minIsWhite: true);
Console.WriteLine($"{format.BytesPerPixel} bytes/pixel, planar: {format.IsPlanar}");
PixelFormat anyOther = Lcms2.Native.Liblcms2.TYPE_ABGR_16_SE; // every constant converts implicitly
using var context = Lcms2Context.Create();
context.AdaptationState = 0.0;
context.SetAlarmCodes([0xFFFF, 0, 0xFFFF]);
using var profile = IccProfile.CreateSrgb(context);
try
{
using var profile = IccProfile.Open("broken.icc");
}
catch (Lcms2Exception ex)
{
Console.WriteLine($"{ex.ErrorCode}: {ex.NativeMessage}");
}
Lcms2Log.MessageLogged += (_, e) => Console.WriteLine($"[lcms2] {e.ErrorCode}: {e.Message}");
using Lcms2.Native;
unsafe
{
var profile = Liblcms2.cmsCreate_sRGBProfile();
var space = Liblcms2.cmsGetColorSpace(profile);
Liblcms2.cmsCloseProfile(profile);
}
Testing
dotnet test
Samples
dotnet run --project samples/Lcms2.NET.ProfileInfoSample -- [profile.icc]
dotnet run --project samples/Lcms2.NET.TransformSample -- [in.ppm out.ppm src.icc dst.icc]
dotnet run --project samples/Lcms2.NET.NamedColorSample -- [press.icc]
Regenerating the bindings
git submodule update --init
dotnet tool restore
sh eng/generate.sh
Requires a system clang for its builtin-header resource directory.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.19.1 | 445 | 7/31/2026 |