Класс ColorTransformsOptimizer
В этом разделе
Содержит статические методы для создания оптимизированных версий преобразований цвета.
Объектная модель
Синтаксис
'Declaration
Public MustInherit NotInheritable Class ColorTransformsOptimizer
public static class ColorTransformsOptimizer
public __gc abstract __sealed class ColorTransformsOptimizer
public ref class ColorTransformsOptimizer abstract sealed
Пример
Вот пример, показывающий, как получить составное преобразование цвета из исходного и целевого профилей ICC и оптимизировать его.
''' <summary>
''' Creates a composite color transform from specified source and destination RGB profiles
''' and returns optimized thread-unsafe color transform.
''' </summary>
Public Shared Function GetOptimizedRgbTransform(sourceRgbProfileFilename As String, destRgbProfileFilename As String) As Vintasoft.Imaging.ColorManagement.ColorTransform
' create ICC profiles
Using sourceIccProfile As New Vintasoft.Imaging.ColorManagement.Icc.IccProfile(sourceRgbProfileFilename)
Using destIccProfile As New Vintasoft.Imaging.ColorManagement.Icc.IccProfile(destRgbProfileFilename)
' check device color space of the source profile
If sourceIccProfile.DeviceColorSpace <> Vintasoft.Imaging.ColorSpaceType.sRGB Then
Throw New System.ArgumentException("Source profile is not RGB profile.")
End If
' check device color space of the destination profile
If destIccProfile.DeviceColorSpace <> Vintasoft.Imaging.ColorSpaceType.sRGB Then
Throw New System.ArgumentException("Destination profile is not RGB profile.")
End If
' get transforms from device color space to PCS
Dim deviceToPcsTransform As Vintasoft.Imaging.ColorManagement.ColorTransform = sourceIccProfile.GetDeviceToPcsTransform()
' get transforms from PCS to device color space
Dim pcsToDeviceTransform As Vintasoft.Imaging.ColorManagement.ColorTransform = destIccProfile.GetPcsToDeviceTransform()
' composite color transform
Dim composition As Vintasoft.Imaging.ColorManagement.ColorTransform
If sourceIccProfile.PcsColorSpace = destIccProfile.PcsColorSpace Then
' create simple composite color transform
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(deviceToPcsTransform, pcsToDeviceTransform)
Else
If sourceIccProfile.PcsColorSpace = Vintasoft.Imaging.ColorSpaceType.PCSXYZ Then
' create simple composite color transform with intermediate PCSXYZ->PCSLab conversion
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(deviceToPcsTransform, Vintasoft.Imaging.ColorManagement.ColorTransforms.PcsXyzToPcsLabD50, pcsToDeviceTransform)
Else
' create simple composite color transform with intermediate PCSLab->PCSXYZ conversion
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(deviceToPcsTransform, Vintasoft.Imaging.ColorManagement.ColorTransforms.PcsLabToPcsXyzD50, pcsToDeviceTransform)
End If
End If
' return optimized color transform
Return Vintasoft.Imaging.ColorManagement.ColorTransformsOptimizer.GetOptimizedTransform(composition, False)
End Using
End Using
End Function
/// <summary>
/// Creates a composite color transform from specified source and destination RGB profiles
/// and returns optimized thread-unsafe color transform.
/// </summary>
public static Vintasoft.Imaging.ColorManagement.ColorTransform GetOptimizedRgbTransform(
string sourceRgbProfileFilename, string destRgbProfileFilename)
{
// create ICC profiles
using (Vintasoft.Imaging.ColorManagement.Icc.IccProfile sourceIccProfile =
new Vintasoft.Imaging.ColorManagement.Icc.IccProfile(sourceRgbProfileFilename))
using (Vintasoft.Imaging.ColorManagement.Icc.IccProfile destIccProfile =
new Vintasoft.Imaging.ColorManagement.Icc.IccProfile(destRgbProfileFilename))
{
// check device color space of the source profile
if (sourceIccProfile.DeviceColorSpace != Vintasoft.Imaging.ColorSpaceType.sRGB)
{
throw new System.ArgumentException("Source profile is not RGB profile.");
}
// check device color space of the destination profile
if (destIccProfile.DeviceColorSpace != Vintasoft.Imaging.ColorSpaceType.sRGB)
{
throw new System.ArgumentException("Destination profile is not RGB profile.");
}
// get transforms from device color space to PCS
Vintasoft.Imaging.ColorManagement.ColorTransform deviceToPcsTransform = sourceIccProfile.GetDeviceToPcsTransform();
// get transforms from PCS to device color space
Vintasoft.Imaging.ColorManagement.ColorTransform pcsToDeviceTransform = destIccProfile.GetPcsToDeviceTransform();
// composite color transform
Vintasoft.Imaging.ColorManagement.ColorTransform composition;
if (sourceIccProfile.PcsColorSpace == destIccProfile.PcsColorSpace)
{
// create simple composite color transform
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(
deviceToPcsTransform,
pcsToDeviceTransform);
}
else
{
if (sourceIccProfile.PcsColorSpace == Vintasoft.Imaging.ColorSpaceType.PCSXYZ)
{
// create simple composite color transform with intermediate PCSXYZ->PCSLab conversion
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(
deviceToPcsTransform,
Vintasoft.Imaging.ColorManagement.ColorTransforms.PcsXyzToPcsLabD50,
pcsToDeviceTransform);
}
else
{
// create simple composite color transform with intermediate PCSLab->PCSXYZ conversion
composition = Vintasoft.Imaging.ColorManagement.SimpleCompositeColorTransform.Create(
deviceToPcsTransform,
Vintasoft.Imaging.ColorManagement.ColorTransforms.PcsLabToPcsXyzD50,
pcsToDeviceTransform);
}
}
// return optimized color transform
return Vintasoft.Imaging.ColorManagement.ColorTransformsOptimizer.GetOptimizedTransform(composition, false);
}
}
Иерархия наследования
System.Object
 Vintasoft.Imaging.ColorManagement.ColorTransformsOptimizer
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также