Table of Contents

Method TryCreateLinearizedColorContext

Namespace
PaintDotNet.Direct2D1
Assembly
PaintDotNet.Windows.Framework.dll

TryCreateLinearizedColorContext(IDeviceColorContextFactory, IDeviceColorContext)

Creates a linearized version of the given color context. This removes the transfer curve (TRC) and enables the use of linear gamma with most color contexts. If the color context cannot be linearized then null will be returned. If the color context is already linearized then a copy will be made using the given factory.

public static IDeviceColorContext? TryCreateLinearizedColorContext(this IDeviceColorContextFactory factory, IDeviceColorContext baseColorContext)

Parameters

factory IDeviceColorContextFactory
baseColorContext IDeviceColorContext

Returns

IDeviceColorContext

Remarks

This method is useful when you want to standardize on rendering using linear gamma. By using an ICommandList and a ColorManagementEffect, you can issue drawing commands that are automatically converted from one color space to another.

Not all color contexts can be linearized. If you always require the use of a linear color space, you should use scRGB as a fallback. scRGB is sometimes referred to by Microsoft as CCCS, or Canonical Composition Color Space. It is possible to convert to and from scRGB without color gamut clipping.

This uses the same algorithm as TryCreateLinearizedColorContext(IImagingFactory, IColorContext).