VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging Namespace / VintasoftImage Class / CreateImagesBasedOnSourceImageDecoders Method
An array of the source images.
Example



In This Topic
    CreateImagesBasedOnSourceImageDecoders Method
    In This Topic
    Creates a new array of images that based on decoders of source images.
    Syntax
    'Declaration
     
    Public Shared Function CreateImagesBasedOnSourceImageDecoders( _
       ByVal sourceImages() As VintasoftImage _
    ) As VintasoftImage()
    public static VintasoftImage[] CreateImagesBasedOnSourceImageDecoders( 
       VintasoftImage[] sourceImages
    )
    public: static VintasoftImage*[]* CreateImagesBasedOnSourceImageDecoders( 
       VintasoftImage*[]* sourceImages
    ) 
    public:
    static array<VintasoftImage^>^ CreateImagesBasedOnSourceImageDecoders( 
       array<VintasoftImage^>^ sourceImages
    ) 

    Parameters

    sourceImages
    An array of the source images.

    Return Value

    An array of images based on decoders of the source images.
    Remarks
    This method can be used when the same array of VintasoftImage objects must be used with different decoding (color management) settings, for example, the same images must be viewed and printed with different color management settings.

    Created images must be destroyed using the Dispose method when images are not necessary any more.
    Example
    This example shows how to view the same images in 2 viewers with different color management settings.
    ''' <summary>
    ''' View images in 2 image viewers with different output ICC profiles.
    ''' </summary>
    Public Shared Sub ViewImages(images As Vintasoft.Imaging.VintasoftImage(), viewer1 As Vintasoft.Imaging.UI.ImageViewer, outputRgbIccProfile1 As String, viewer2 As Vintasoft.Imaging.UI.ImageViewer, outputRgbIccProfile2 As String)
        AddImagesToViewer(images, viewer1, outputRgbIccProfile1)
        AddImagesToViewer(images, viewer2, outputRgbIccProfile2)
    End Sub
                
    ''' <summary>
    ''' Creates new images using decoders of source images and
    ''' shows new images in specified viewer with specified output ICC profile.
    ''' </summary>
    Private Shared Sub AddImagesToViewer(sourceImages As Vintasoft.Imaging.VintasoftImage(), viewer As Vintasoft.Imaging.UI.ImageViewer, outputRgbIccProfile As String)
        ' create ICC profile
        Dim profile As New Vintasoft.Imaging.ColorManagement.Icc.IccProfile(outputRgbIccProfile)
        ' create new images based on decoder(s) of source images
        Dim images1 As Vintasoft.Imaging.VintasoftImage() = Vintasoft.Imaging.VintasoftImage.CreateImagesBasedOnSourceImageDecoders(sourceImages)
        For i As Integer = 0 To images1.Length - 1
            Dim sourceImage As Vintasoft.Imaging.VintasoftImage = sourceImages(i)
            Dim newImage As Vintasoft.Imaging.VintasoftImage = images1(i)
            ' set new color management settions
            newImage.DecodingSettings = New Vintasoft.Imaging.Codecs.Decoders.DecodingSettings()
            If sourceImage.DecodingSettings IsNot Nothing AndAlso sourceImage.DecodingSettings.ColorManagement IsNot Nothing Then
                newImage.DecodingSettings.ColorManagement = New Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings(sourceImage.DecodingSettings.ColorManagement)
            Else
                newImage.DecodingSettings.ColorManagement = New Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings()
            End If
            newImage.DecodingSettings.ColorManagement.OutputRgbProfile = profile
        Next
        ' add new images to the viewer
        viewer.Images.AddRange(images1)
    End Sub
    /// <summary>
    /// View images in 2 image viewers with different output ICC profiles.
    /// </summary>
    public static void ViewImages(
        Vintasoft.Imaging.VintasoftImage[] images,
        Vintasoft.Imaging.UI.ImageViewer viewer1, string outputRgbIccProfile1,
        Vintasoft.Imaging.UI.ImageViewer viewer2, string outputRgbIccProfile2)
    {
        AddImagesToViewer(images, viewer1, outputRgbIccProfile1);
        AddImagesToViewer(images, viewer2, outputRgbIccProfile2);
    }
                
    /// <summary>
    /// Creates new images using decoders of source images and
    /// shows new images in specified viewer with specified output ICC profile.
    /// </summary>
    private static void AddImagesToViewer(
        Vintasoft.Imaging.VintasoftImage[] sourceImages, 
        Vintasoft.Imaging.UI.ImageViewer viewer, string outputRgbIccProfile)
    {
        // create ICC profile
        Vintasoft.Imaging.ColorManagement.Icc.IccProfile profile = 
            new Vintasoft.Imaging.ColorManagement.Icc.IccProfile(outputRgbIccProfile);
        // create new images based on decoder(s) of source images
        Vintasoft.Imaging.VintasoftImage[] images1 = 
            Vintasoft.Imaging.VintasoftImage.CreateImagesBasedOnSourceImageDecoders(sourceImages);
        for (int i = 0; i < images1.Length; i++)
        {
            Vintasoft.Imaging.VintasoftImage sourceImage = sourceImages[i];
            Vintasoft.Imaging.VintasoftImage newImage = images1[i];
            // set new color management settions
            newImage.DecodingSettings = new Vintasoft.Imaging.Codecs.Decoders.DecodingSettings();
            if (sourceImage.DecodingSettings != null &&
                sourceImage.DecodingSettings.ColorManagement != null)
                newImage.DecodingSettings.ColorManagement =
                    new Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings(
                        sourceImage.DecodingSettings.ColorManagement);
            else
                newImage.DecodingSettings.ColorManagement = 
                    new Vintasoft.Imaging.ColorManagement.ColorManagementDecodeSettings();
            newImage.DecodingSettings.ColorManagement.OutputRgbProfile = profile;
        }
        // add new images to the viewer
        viewer.Images.AddRange(images1);
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also