VintaSoft Imaging .NET SDK 15.2: Documentation for .NET developer
Vintasoft.Imaging.ColorManagement Namespace / ColorManagementDecodeSettings Class / OutputCmykProfile Property
Syntax Example Requirements SeeAlso
In This Topic
OutputCmykProfile Property (ColorManagementDecodeSettings)
In This Topic
Gets or sets the IccProfile used as an output profile for CMYK images.
Syntax

Property Value

Default value is null, i.e. the color profile is not used.
Example

Here is an example that shows how to save image as CMYK JPEG image:


''' <summary>
''' Saves image as CMYK JPEG image.
''' </summary>
''' <param name="sourceImage">The source image.</param>
''' <param name="iccProfile">The ICC profile.</param>
''' <param name="outFilePath">The output file path.</param>
Public Sub SaveCmykJpegImage(sourceImage As Vintasoft.Imaging.VintasoftImage, iccProfile As Vintasoft.Imaging.ColorManagement.Icc.IccProfile, outFilePath As String)
    If iccProfile Is Nothing Then
        Throw New System.ArgumentNullException()
    End If
    If iccProfile.DeviceColorSpace <> Vintasoft.Imaging.ColorSpaceType.CMYK Then
        Throw New System.InvalidOperationException()
    End If

    ' convert image to BGR24 format
    Dim converter As New Vintasoft.Imaging.ImageProcessing.ChangePixelFormatToBgrCommand(Vintasoft.Imaging.PixelFormat.Bgr24)
    Using image As Vintasoft.Imaging.VintasoftImage = converter.Execute(sourceImage)
        ' create new color management decoding settings
        Dim colorManagement As New Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings()
        ' set output CMYK profile
        colorManagement.OutputCmykProfile = iccProfile
        ' get color transform (BGR to CMYK)
        Dim colorTransform As Vintasoft.Imaging.ColorManagement.ColorTransform = colorManagement.GetColorTransform(Vintasoft.Imaging.ColorSpaceFormats.Bgr, Vintasoft.Imaging.ColorSpaceFormats.Cmyk)

        ' create a color transform command
        Dim command As New Vintasoft.Imaging.ImageProcessing.Color.ColorTransformCommand()
        ' set color transform
        command.ColorTransform = colorTransform
        ' set format of channels of result image (4 channels to 8 bits)
        command.OutputChannelsFormat = New Vintasoft.Imaging.BitmapChannelsFormat(4, 8)
        command.ExecuteInPlace(image)

        ' create JPEG encoder
        Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.JpegEncoder()
        ' create settings of JPEG encoder
        Dim settings As New Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings()
        ' disable subsampling
        settings.IsSubsamplingDisabled = True
        Dim table As Integer() = New Integer() {8, 6, 6, 7, 6, 5, _
            8, 7, 7, 7, 9, 9, _
            8, 10, 12, 20, 13, 12, _
            11, 11, 12, 25, 18, 19, _
            15, 20, 29, 26, 31, 30, _
            29, 26, 28, 28, 32, 36, _
            46, 39, 32, 34, 44, 35, _
            28, 28, 40, 55, 41, 44, _
            48, 49, 52, 52, 52, 31, _
            39, 57, 61, 56, 50, 60, _
            46, 51, 52, 50}
        ' set quantization table of channels
        settings.QuantizationTables = New Integer()() {table, table, table, table}
        encoder.Settings = settings
        ' save image as CMYK JPEG image
        image.Save(outFilePath, encoder)
    End Using
End Sub


/// <summary>
/// Saves image as CMYK JPEG image.
/// </summary>
/// <param name="sourceImage">The source image.</param>
/// <param name="iccProfile">The ICC profile.</param>
/// <param name="outFilePath">The output file path.</param>
public void SaveCmykJpegImage(
    Vintasoft.Imaging.VintasoftImage sourceImage,
    Vintasoft.Imaging.ColorManagement.Icc.IccProfile iccProfile,
    string outFilePath)
{
    if (iccProfile == null)
        throw new System.ArgumentNullException();
    if (iccProfile.DeviceColorSpace != Vintasoft.Imaging.ColorSpaceType.CMYK)
        throw new System.InvalidOperationException();

    // convert image to BGR24 format
    Vintasoft.Imaging.ImageProcessing.ChangePixelFormatToBgrCommand converter =
        new Vintasoft.Imaging.ImageProcessing.ChangePixelFormatToBgrCommand(Vintasoft.Imaging.PixelFormat.Bgr24);
    using (Vintasoft.Imaging.VintasoftImage image = converter.Execute(sourceImage))
    {
        // create new color management decoding settings
        Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings colorManagement =
            new Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings();
        // set output CMYK profile
        colorManagement.OutputCmykProfile = iccProfile;
        // get color transform (BGR to CMYK)
        Vintasoft.Imaging.ColorManagement.ColorTransform colorTransform = colorManagement.GetColorTransform(
            Vintasoft.Imaging.ColorSpaceFormats.Bgr,
            Vintasoft.Imaging.ColorSpaceFormats.Cmyk);

        // create a color transform command
        Vintasoft.Imaging.ImageProcessing.Color.ColorTransformCommand command =
            new Vintasoft.Imaging.ImageProcessing.Color.ColorTransformCommand();
        // set color transform
        command.ColorTransform = colorTransform;
        // set format of channels of result image (4 channels to 8 bits)
        command.OutputChannelsFormat = new Vintasoft.Imaging.BitmapChannelsFormat(4, 8);
        command.ExecuteInPlace(image);

        // create JPEG encoder
        Vintasoft.Imaging.Codecs.Encoders.JpegEncoder encoder =
            new Vintasoft.Imaging.Codecs.Encoders.JpegEncoder();
        // create settings of JPEG encoder
        Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings settings =
            new Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings();
        // disable subsampling
        settings.IsSubsamplingDisabled = true;
        int[] table = new int[] { 
            8, 6, 6, 7, 6, 5, 8, 7,
            7, 7, 9, 9, 8, 10, 12, 20,
            13, 12, 11, 11, 12, 25, 18, 19, 
            15, 20, 29, 26, 31, 30, 29, 26, 
            28, 28, 32, 36, 46, 39, 32, 34,
            44, 35, 28, 28, 40, 55, 41, 44, 
            48, 49, 52, 52, 52, 31, 39, 57,
            61, 56, 50, 60, 46, 51, 52, 50 };
        // set quantization table of channels
        settings.QuantizationTables = new int[][] { table, table, table, table };
        encoder.Settings = settings;
        // save image as CMYK JPEG image
        image.Save(outFilePath, encoder);
    }
}

Requirements

Target Platforms: .NET 11; .NET 10; .NET 9; .NET 8; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also